Reset MySQL root password

This is a quick tutorial to reset your MySQL root pass­word. It does require root access on your server. If you have for­got­ten that pass­word wait for another arti­cle.

1. Log in as root and stop the mysql dae­mon.

# service mysqld stop

2. Start up the mysql dae­mon and skip the grant tables which store the pass­words.

# mysqld_safe --skip-grant-tables

3. Now you should be able to con­nect to mysql with­out a pass­word.

# mysql --user=root mysql

4. Update root password

update user set Password=PASSWORD('new-password') where user='root';

5. Finally kill your run­ning mysqld process, then restart it nor­mally.

# kill -9 <mysqld pid>
# service mysqld start

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s