Skip to content

Instantly share code, notes, and snippets.

@lmammino
Created March 17, 2014 17:18
Show Gist options
  • Save lmammino/9603885 to your computer and use it in GitHub Desktop.
Save lmammino/9603885 to your computer and use it in GitHub Desktop.
Recover Mysql root password

1. Stopping the mysql daemon

/etc/init.d/mysql stopRun

2. Disable security checks and restart mysql

mysqld_safe --skip-grant-tables &

3. Enter as root (use whatever you want when it asks for a password)

mysql -u root -p

4. Change the root password and exit

use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User="root";
exit;

5. reboot mysql (will re-enable security checks)

sudo service mysql restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment