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.
1. Using the MySQL Console
On the wamp menu go to MySQL –> MySQL console.
Hit enter as there is no password. Enter the following commands:
mysql> SET PASSWORD for 'root'@'localhost' = password('enteryourpassword');
mysql> SET PASSWORD for 'root'@'127.0.0.1' = password('enteryourpassword');
mysql> SET PASSWORD for 'root'@'::1' = password('enteryourpassword');
That’s it, I keep the passwords the same to keep things simple. If you want to check the user’s table to see that the info has been updated just enter the additional commands as shown below. This is a good option to check that you have indeed entered the same password for all hosts.
2. Using SQL Buddy
This is the way I typically do it. Just open SQL Buddy and go to the Users option on the left. Select all host with a user root and click ‘edit’.
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’.
That’s 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:
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.
Hope this post has helped in your local web development efforts.
If you have any feedback or suggestions please leave a comment on the section below.
Thanks for visiting 🙂