Reset the Root MySQL Password on Ubuntu 10.04

It’s a commonality among sleep-deprived developers to set up a sandbox at 3AM and wake up not remembering the passwords that were set before the retreat into la-la land. Well, resetting the root user’s administrative password for MySQL is a little tedious, but it’s not impossible:

  • sudo /etc/init.d/mysql stop
  • sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
    You will now be able to log into MySQL as root with no password, since you have launched the MySQL daemon with the flag to skip the privilege index.
  • mysql -u root
    • FLUSH PRIVILEGES;
    • SET PASSWORD FOR root@'localhost' = PASSWORD('password');
    • UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
    • FLUSH PRIVILEGES;
  • sudo /etc/init.d/mysql stop
  • sudo /etc/init.d/mysql start

One Response to “Reset the Root MySQL Password on Ubuntu 10.04”

  1. KOD  on November 16th, 2011

    Hi Thanks so much !!!!!!!! It works


Leave a Reply