How To Set The MySQL Root Password in Localhost Using WAMP
How To Set The MySQL Root Password in Localhost Using WAMP
In this post I will like to show you how to set the MySQL root account password in 3 different ways.
This is a very important step in your WAMP Server setup and although is not required for local
development, I still suggest creating a root password as good practice. If you are using WAMP to share
your website online then I STRONGLY recommend a strong password with upper and lower case letters
and numbers and perhaps throwing in a couples of symbols too.
The 3 ways I will be discussing here are, 1) by going to the MySQL console and typing the appropriate
commands, 2) via the GUI (graphical user interface) using SQL Buddy and 3) via PHPMyAdmin.
Lets begin,
1. Using the MySQL Console
On the wamp menu go to MySQL > MySQL console.
Enter your password for all users and hit submit for each user. Each time you hit submit you will see a
message: Your changes were saved to the database.
Thats it. And again you can check the User table in the mysql database to check that you have entered
the same password for all hosts.
SQL Buddy will log you out and take you back to the login screen after once you have changed the root
password. Have no fear, just enter your new password on the log in screen and you should be fine.
3. Using phpMyAdmin
Go to http://localhost/phpmyadmin/ and click on USER
On one of the root accounts click on Edit Privileges. Enter the new password twice and click on GO. Do
this for the remaining root accounts. I suggest making the password the same for all three accounts.
Just like SQL Buddy, phpMyAdmin will log you out once you have changed the root password. In this
case, you will get an error if you have not configured phpMyAdmin to prompt you for a password.
Here is how to fix this error:
Error #1045 Access denied for user root@locahost (using password: yes)
Open the config.inc.php file found in C:\wamp\apps\phpmyadmin4.1.x and look for /* Authentication
type */ around line 28.
Set your password for the root account by entering it between the single quotes in the following line:
$cfg['Servers'][$i]['password'] = 'mypassword';
Replace mypassword with your own password of course. This should get you back to phpMyAdmin.