How to Reset MySQL root password

(1/1)

Richard Marks:
How to Reset MySQL root password

Ever find yourself forgetting what you set your MySQL root password to, since you haven't used your db in ages?
I do...too much in fact. ;D
So Here is how to save yourself grief.

First you must stop the mysql service:
Code:

$ sudo /etc/init.d/mysql stop


Now start the MySQL server without a password:
Code:

$ sudo mysqld_safe --skip-grant-tables &


Now connect to the MySQL server using the mysql client:
Code:

$ sudo mysql -u root


Now setup new MySQL root user password:
Code:

mysql> use mysql;
mysql> update user set password=PASSWORD("your new password goes here") where User='root';
mysql> flush privileges;
mysql> quit


Now stop the MySQL server:
Code:

$ sudo /etc/init.d/mysql stop


Finally, start your MySQL server and test that you can now login:
Code:

$ sudo /etc/init.d/mysql start
$ mysql -u root -p


Presto! 8)

Navigation

[0] Message Index