Skip to content

Instantly share code, notes, and snippets.

@taichiman
Last active December 28, 2015 05:09
Show Gist options
  • Save taichiman/7447319 to your computer and use it in GitHub Desktop.
Save taichiman/7447319 to your computer and use it in GitHub Desktop.
MySQL, mysql
You can reset the root password by running the server with --skip-grant-tables and logging in without a password by running the following as root (or with sudo):
# service mysql stop
# mysqld_safe --skip-grant-tables &
$ mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("YOUR-NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
# service mysql stop
# service mysql start
$ mysql -u root -p
Now you should be able to login as root with your new password.
It is also possible to find the query that reset the password in /home/$USER/.mysql_history or /root/.mysql_history of the user who reset the password, but the above will always work.
===
mysqldump --all-databases --all-routines -u root -p > ~/fulldump.sql
===
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment