Skip to content

Instantly share code, notes, and snippets.

@javascripto
Created July 5, 2020 01:50
Show Gist options
  • Select an option

  • Save javascripto/8b16dcc7da5a62395a5b04ac7181a63d to your computer and use it in GitHub Desktop.

Select an option

Save javascripto/8b16dcc7da5a62395a5b04ac7181a63d to your computer and use it in GitHub Desktop.
Steps to reset mysql password
sudo /etc/init.d/mysql stop
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
cat << EOF > reset.sql
use mysql;
update user set authentication_string=password('') where user='root';
rupdate user set plugin="mysql_native_password" where User='root';
flush privileges;
quit;
EOF
sudo mysqld_safe --skip-grant-tables &
sudo mysql -u root << reset.sql
rm reset.sql
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