Resetting MySQL root password under Ubuntu

Posted on June 7, 2007 
Filed Under Linux

Having set up my Ubuntu box a little while ago, I had actually forgotten what I had set my MySQL root password to. I was trying to set something up today and had a need to reset it. Thankfully, if you have root access on a linux box, its a simple procedure to fix. I have Ubuntu 7.04 (Feisty Fawn) and MySQL 5.0.38.

Stop the MySQL server:

sudo /etc/init.d/mysql stop

Start the MySQL configuration without checking the root password:

sudo mysqld –skip-grant-tables &

Log in as root to MySQL (without a password):

mysql -u root mysql

Replace the password with your new password:

UPDATE user SET Password=PASSWORD(’YOURNEWPASSWORD’) WHERE User=’root’; FLUSH PRIVILEGES; exit;

And that’s it!

Comments

Leave a Reply