Skip to content

Instantly share code, notes, and snippets.

@petasittek
Created October 14, 2011 17:08
Show Gist options
  • Save petasittek/1287696 to your computer and use it in GitHub Desktop.
Save petasittek/1287696 to your computer and use it in GitHub Desktop.
MySQL - root password reset
sudo /etc/init.d/mysql stop
# we have to --skip-networking to prevent connections out of localhost because mysql will now run absolutely unprotected
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
mysql -u root
# reload privileges from grant tables (free cached memory)
FLUSH PRIVILEGES;
USE mysql;
# set your new password
UPDATE user SET Password = PASSWORD('new password') WHERE Host = 'localhost' AND User = 'root';
# reload the privileges again
FLUSH PRIVILEGES;
# restart
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment