If you have root access to a linux server and you don’t have the root mysql password, but need it, then you can easily reset the root mysql password in just a few commands. These commands probably differ depending on what linux distro you use. I was using Ubuntu 9.04 (Jaunty Jackalope) when I wrote this.

Firstly you will want to turn the mysql service off.



codytaylor@server:~$ sudo /etc/init.d/mysql stop * Stopping MySQL database server mysqld

codytaylor@server:~$ sudo mysqld_safe --skip-grant-tables --skip-networking &

codytaylor@server:~$ mysql -u root mysql mysql> UPDATE user SET Password=PASSWORD('password') WHERE User='root'; mysql> FLUSH PRIVILEGES;

codytaylor@server:~$ sudo /etc/init.d/mysql restart

Now we restart the mysql server with the ‘skip-grant-tables’ option which basically allows anyone to do whatever they like. It’s usually preferable to include the ‘skip-networking’ option so that only localhost (you) have access to the naked database.Now all that is left is actually changing the root password. Log into the mysql monitor and change the root password.Those commands will reset the root mysql password to ‘password’. Now you’ll probably want to restart the mysql service and have it run normally.

If you are using windows and you want to reset the mysql root password then check the mysql documentation.