Knowledge Base/Server Administration

How do I reset MySQL's root password?

posted this on August 10, 2012, 2:00 PM

First, check the password that is located in: /root/.my.cnf  ... This is usually the first root password the server was given once cpanel is installed. If that does not work, you will need to reset the mysqld root password.

First, stop the mysqld, usually: /etc/rc.d/init.d/mysql stop

Then stop chkservd to keep it from interfering with mysqld while you work on it with /etc/rc.d/init.d/chkservd stop

Now, we need to start up mysqld, but, without the grant tables:

Run: mysqld --skip-grant-tables -u mysql &

After it's started, it's time to change the password. Run the following three commands:

mysql -u root mysql
UPDATE user SET Password=PASSWORD('new_password') WHERE user='root';

Now you just killall -9 mysqld and start it up normally with its safe_mysqld script.

Topic is closed for comments