Resetting MySQL Passwords

I downloaded a Ubuntu 8.10 VMPlanet.net image with MySQL server, but the root password was set to something other than the standard vmplanet.net password. Logging in without a password or username didn’t give me enough permissions to set my own users and change passwords. Here is the solution for this problem (thanks Keystone IT Tech!).

Basically, it comes down to killing mysql server, re-running it without the grant tables, setting the password and then restarting it in normal mode. To quote the linked website (Keystone IT Tech):

sudo su
kill `cat /var/run/mysqld/mysqld.pid`
mysqld --skip-grant-tables &
mysql -u root
UPDATE mysql.user SET Password=PASSWORD ('newpassword') WHERE User = 'root';
exit
kill `cat /var/run/mysqld/mysqld.pid`
mysqld &
mysql -u root -p

Very cool.

Leave a Reply