Skip to content

Instantly share code, notes, and snippets.

@gggordon
Created October 26, 2019 23:12
Show Gist options
  • Save gggordon/939661534db7918e1723641f47beb4d1 to your computer and use it in GitHub Desktop.
Save gggordon/939661534db7918e1723641f47beb4d1 to your computer and use it in GitHub Desktop.
Reset MYSQL PASSWORD
#!/usr/bin/env bash
# Resetting mysql default password
NEW_PASSWORD='password'
su root
systemctl stop mysqld
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables --skip-networking"
echo "FLUSH PRIVILEGES;ALTER USER 'root'@'localhost' IDENTIFIED BY '$NEW_PASSWORD';" > refresh_user.sql
mysql -uroot < refresh_user.sql
rm refresh_user.sql
systemctl unset-environment MYSQLD_OPTS
systemctl restart mysqld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment