Change MySQL root password in WAMP server

The MySQL console

Open MySQL console from WAMP menu. Wamp MySQL Console

Alternatively you can launch ‘MySQL’ from command prompt.


Setting a password for root user

The WAMP bundle does not have a password for the root user by default. You can login right away by hitting the <Enter> key (refer image below).

mysql console from cmd prompt

At the “mysql>” cmd prompt, enter the following line, and press ENTER.

SET PASSWORD FOR root@localhost=PASSWORD('Enter Your Password here');

Note: Replace your password in the place ‘Enter Your Password here’ and make sure you have typed inside the quotes.

A successful password change will look like this.

MySQL password change window

Now, you have changed the password for MySQL’s root user. But phpMyAdmin will attempt to connect to MySQL using NO password (as configured in, throwing an error as shown below.

Error 1045 - Access denied for user 'root'@'localhost' (using password NO)

To update the mysql password set in phpMyAdmin’s configuration:

  1. Browse to WampServer phpmyadmin folder, for ex: Installed drive:\Wamp\apps\phpmyadmin3.5.1
  2. Open the file using Notepad or Wordpad. The file should look like this:
  3. Replace the empty quotes with the password that you have set for the MySQL and change the ‘AllowNoPassword’ value to false. For ex.
    MySQL password variable
  4. Save the file and you are done. Now go back to browser and press ” Ctrl + F5 “.

Update password for root user

To update the password at a later stage, use the following command in MySQL console.

mysql> UPDATE mysql.user SET Password=PASSWORD('Your new Password') WHERE User='root';

And do not forget to update your new password in phpMyAdmin’s config file.

Leave a Reply