Ubuntu 10.04 Reset the MySQL Root Password

The method here has been posted on several blogs and forums out there, and it does work.  however, there is one extra thing I ran into in Ubuntu 10.04 that I am going to add to it.

First the method.

The idea is to start up MySQL with grant tables disabled on the mysql database so that you can login as root without a password and change your password in said database.

In a Terminal issue the following commands:

$sudo service mysql stop  (to stop the MySQL service)

$sudo mysqld –skip-grant-tables &  (to start it up manually and skip the grant tables)

$mysql -u root mysql  (to login and use the mysql table as root without a password)

Now that you have a MySQL prompt enter the following

>UPDATE user SET Password=PASSWORD(‘newpassword’) WHERE User=’root’;





This will have set your new password in the mysql table.  Now the last part is to restart MySQL.  You can issue your sudo service mysql stop, but that is the difference I found in Ubuntu 10.04.  The normal scripts do not stop the manual MySQL process you started.  Instead simply kill the proccess.

$ps ax | grep mysql

You should see mysqld –skip-grant-tables listed, note the PID#

$sudo kill -9 PID#


$sudo service mysql start

It should start normally and allow you to login as root with the new password you set.

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>