Saturday, December 17, 2011

MySQL - Changing root Password

Problem

The default password for root user in mysql is nothing. i.e no password is required for root user to login and I had to change it as PHPMyAdmin kept on complaining about it and it makes sense to change it too.

Solution

1. Open a new command prompt window and navigate to the mysql bin directory for me it was here - D:\WAMP\bin\mysql\mysql5.1.30\bin

2. Type mysql -u root to login as root, remember it doesnt need a password

3. When you are at the mysql prompt [mysql>] type the following, replace new_password to anything that you want to change it to and wait for update confirmation.
    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');

4. To test whether this has taken exit from the prompt and try to relogin using mysql -u root. System wouldnt allow now with no password, try to do mysql -u root -p and at the prompt provide your new password and it should let you in.

No comments:

Post a Comment