How to reset MYSQL password in Ubuntu!

You can reset the root password by running the server with –skip-grant-tables and logging in without a password by running the following as root (or with sudo):

# /etc/init.d/mysql stop
# mysqld_safe –skip-grant-tables &
$ mysql -u root

mysql> use mysql;
mysql> update user set password=PASSWORD(“YOUR-NEW-ROOT-PASSWORD”) where User=’root’;
mysql> flush privileges;
mysql> quit

# /etc/init.d/mysql stop
# /etc/init.d/mysql start
$ mysql -u root -p

Now you should be able to login as root.

It is also possible to find the query that reset the password in /home/…/.mysql_history or /root/.mysql_history of the user who reset the password, but the above will always work.