Monday, 30 March 2015

How to change mysql password

Assuming you have a working mysql installation and know the current password...
The instructions here are for a Linux/Unix mysql installation, however should also work for MS Windows using mysql.exe.

Open a terminal and type the following to change the admin password
mysqladmin –u root –p'oldpassword' password 'newpassword'
Now login to mysql to change the root password
mysql –u root –p'newpassword'
At the mysql prompt type the following to change the password for the root user
UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
And repeat the following for any user where appropriate
UPDATE mysql.user SET Password=PASSWORD('userpassword') WHERE User='username';
Type quit when done.

No comments:

Post a Comment