Skip to content

Instantly share code, notes, and snippets.

@mtparet
Last active December 2, 2016 10:23
Show Gist options
  • Save mtparet/affd5d48a323ab8dca432bc5b0c5399b to your computer and use it in GitHub Desktop.
Save mtparet/affd5d48a323ab8dca432bc5b0c5399b to your computer and use it in GitHub Desktop.
Reset password mysql 5.7
#!/usr/bin/env bash
set -x
set -e
sudo service mysql stop || echo "mysql not stopped"
sudo stop mysql-5.6 || echo "mysql-5.6 not stopped"
sudo mysqld_safe --skip-grant-tables &
sleep 4
sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;"
sudo kill -9 `sudo cat /var/lib/mysql/mysqld_safe.pid`
sudo kill -9 `sudo cat /var/run/mysqld/mysqld.pid`
sudo service mysql restart
sleep 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment