Skip to content

Instantly share code, notes, and snippets.

@Remiii
Last active August 29, 2015 14:04
Show Gist options
  • Save Remiii/5d16305ca61ba52e3d56 to your computer and use it in GitHub Desktop.
Save Remiii/5d16305ca61ba52e3d56 to your computer and use it in GitHub Desktop.
How to reset passwords (Root and Users) for MySQL

How to reset passwords (Root and Users) for MySQL

$ sudo su

$ /etc/init.d/mysql stop
$ mysqld_safe --skip-grant-tables &
$ mysql -u root

mysql> update user set password=PASSWORD("tmprootpwd") where user='root';
mysql> flush privileges;
mysql> quit

$ /etc/init.d/mysql stop
$ /etc/init.d/mysql start

$ mysql --user=root --password=tmprootpwd

mysql> SET PASSWORD = PASSWORD('myFuckingPwdForRoot');
mysql> SET PASSWORD FOR 'myUser'@'%' = PASSWORD('myFuckingPwdForMyUser');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment