Reset MySQL root password (ubuntu)

Oops! I’ve forgotten MySQL root password.

1)Stop MySQL instance (if it is running)

sudo service mysql stop

2)Startup MySQL instance manually with option –skip-grant-tables and –skip-networking

sudo mysqld_safe --skip-grant-tables  --skip-networking 

3)While MySQL is running from step 2, login to MySQL

mysql --user=root mysql 

4)Execute the following SQL commands to update root password

Update user set Password=PASSWORD('new-password') where user='root';
flush privileges;

5)Remember to stop MySQL instance executed from step 2 after you complete step 4. Lastly run MySQL normally.

sudo service mysql start