Filed under Web Hosting

Today I just had to work on a Linux box (CentOS 5) for which I didn’t knew the root password for MySQL so I had to reset it. If you ever face the same problem, here’s how to do it :

  1. Stop the MySQL daemon : service mysqld stop
  2. Start MySQL in safe mode with the –skip-grant-tables and -u root options in background : mysqld_safe –skip-grant-tables -u root &
  3. Start the command line client as root : mysql -u root
  4. Issue the MySQL command to reset the root password : UPDATE mysql.user SET Password=PASSWORD(‘newpwd’) WHERE User=’root’;
  5. Issue the flush privileges command : FLUSH PRIVILEGES;
  6. Quit the command line tool : quit
  7. Stop the MySQL process : kill `cat /var/run/mysqld/mysqld.pid`
  8. Restart the MySQL daemon : service mysqld start
  9. Log in as root to make sure the new password is active : mysql -u root -p

Here’s a screenshot so you can see how it actually goes :

reset-mysql-root-password.jpg


Related Posts

Comments (0) Posted by Stephane on Monday, August 27th, 2007


You can follow any responses to this entry through the magic of "RSS 2.0" and leave a trackback from your own site.

Post A Comment