Skip to content

Instantly share code, notes, and snippets.

@reanim8ed
Last active November 9, 2022 09:04
Show Gist options
  • Save reanim8ed/1e6bdd9b173adf61608f53eee7f76299 to your computer and use it in GitHub Desktop.
Save reanim8ed/1e6bdd9b173adf61608f53eee7f76299 to your computer and use it in GitHub Desktop.
[Change root password in mysql8] #mysq

Change root password

sudo systemctl stop mysql
sudo systemctl edit mysql

[Service]
ExecStart=
ExecStart=/usr/sbin/mysqld --skip-grant-tables --skip-networking

sudo systemctl daemon-reload
sudo systemctl start mysql
sudo mysql -u root
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password123#@!';
mysql> exit
sudo systemctl revert mysql
sudo systemctl daemon-reload
sudo systemctl restart mysql
mysql -u root -p

Change to remote access:

RENAME USER 'peter'@'localhost' TO 'peter'@'%';
GRANT ALL ON somedb.* TO 'peter'@'%';

https://ostechnix.com/how-to-reset-root-password-in-mysql-8-on-ubuntu-linux/

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