Reset MySQL root Password

by Tweak on April 22, 2011
in Mysql

To reset MySQL root user’s password, follow the following steps.

  1. Terminate all running instances of MySQL server. You can do that either via the RC script (/etc/init.d/<script_name> stop or /user/local/etc/rc.d/<script_name> stop for FreeBSD) or using the tools like kill and pkill. To use kill or pkill, you will have to use ps or pgrep to find out the process names or process ID (PID).

    Using the RC script to do a proper shutdown is safer than using kill or pkill.

  2. Start the MySQL server in safe modemysqld_safe --skip-grant-tables --user=mysql
  3. On another terminal, login to the MySQL server as the root usermysql -u root

    On the MySQL prompt, run the following commands

    USE mysql;
    UPDATE user SET Password=PASSWORD('New-Password') WHERE User='root';
    FLUSH PRIVILEGES;
    \q

  4. Terminate all MySQL server processes. At the least you should have two MySQL processes – mysqld_safe and mysql.
  5. Start your MySQL server normally using the RC script. Now, you can login as root with the new password.

Share and Enjoy:
  • Add to favorites
  • Twitter
  • Facebook
  • Google Bookmarks
  • StumbleUpon
  • Digg
  • del.icio.us
  • MySpace
  • Live
  • Yahoo! Buzz
  • PDF
  • email

Post a Comment