Resetting the root Password for MySQL (Ubuntu)

It happens once in a while when you need to reset your MySql password for the root. Here’s what you do:
there’s a file that contains a password for a ‘debian-sys-maint’ user which is created during the installation. It can be found at: /etc/mysql/debian.cnf . Then you need to log into mysql using ‘debian-sys-maint’ user and the password that you’ve just got from the .conf file.

mysql -u debian-sys-maint -p

Once you’ve entered your password, you need to switch to ‘mysql’ table by issuing the following statement:

use mysql

and run the query to update your root user with the new password:

update user set Password=PASSWORD(’new_password’) WHERE User=’root’;
FLUSH PRIVILEGES; 

You should be all set now with your new root password for your MySQL database.

Bookmark and Share

Tags: , ,

Leave a Reply