Skip to content

Instantly share code, notes, and snippets.

@tsleite
Created January 4, 2021 15:39
Show Gist options
  • Save tsleite/1a4bc1d47dddb2309ebd9a8b720b5502 to your computer and use it in GitHub Desktop.
Save tsleite/1a4bc1d47dddb2309ebd9a8b720b5502 to your computer and use it in GitHub Desktop.
#!/bin/bash
$PWD="<PASSWORD>"
systemctl stop mysqld
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables --user=mysql"
systemctl restart mysqld
mysql -u root -e " \
flush privileges; \
ALTER USER 'root'@'localhost' IDENTIFIED BY '$PWD'; \
flush privileges; \
quit; " \
systemctl unset-environment MYSQLD_OPTS
systemctl restart mysqld
@tsleite
Copy link
Author

tsleite commented Jan 4, 2021

Reset password Mysql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment