Skip to content

Instantly share code, notes, and snippets.

@sathishmanohar
Created April 19, 2013 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sathishmanohar/5419673 to your computer and use it in GitHub Desktop.
Save sathishmanohar/5419673 to your computer and use it in GitHub Desktop.
Instructions to reset lost mysql root password on Ubuntu
#Stop Mysql
sudo /etc/init.d/mysql stop
#Start Mysql in safe mode, but skip user privileges table
sudo mysqld_safe --skip-grant-tables &
#Login to mysql
mysql -u root
#Select mysql db
use mysql;
#Reset Password
update user set password=PASSWORD("mynewpassword") where User='root';
#Flush the privileges
flush privileges;
#Quit out
quit
#Stop Mysql
sudo /etc/init.d/mysql stop
#Start Mysql
sudo /etc/init.d/mysql start
#Try logging in
mysql -u root -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment