How To Recover A Lost MySQL Root Password

To reset the root password for a MySQL instance, enter the following commands in a terminal with root/su privilages.

 

# /etc/init.d/mysqld stop

# mysqld_safe –skip-grant-tables &

# mysql -u root

MySQL will load. Enter the following at the prompt

mysql> use mysql;

mysql> update user set password=PASSWORD(“yourpassword”) where User=’root’;

mysql> flush privileges;

mysql> quit

 

You should now be able to log in as root using the “yourpassword” that you entered.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s