Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
#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