Skip to content

Instantly share code, notes, and snippets.

@mehdi89
Last active November 24, 2022 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehdi89/4d5d733f3106744960130b9098d1bbb3 to your computer and use it in GitHub Desktop.
Save mehdi89/4d5d733f3106744960130b9098d1bbb3 to your computer and use it in GitHub Desktop.
How to set mysql root password after install mysql-server in Ubuntu 22.04
# For DEV Server
sudo systemctl stop mysql.service
sudo systemctl status mysql.service
sudo systemctl set-environment MYSQLD_OPTS="--skip-networking --skip-grant-tables"
sudo systemctl start mysql.service
sudo systemctl status mysql.service
sudo mysql -u root
flush privileges;
USE mysql
ALTER USER 'root'@'%' IDENTIFIED BY 'new_password';
# ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123';
quit;
sudo systemctl unset-environment MYSQLD_OPTS
sudo systemctl revert mysql
sudo killall -u mysql
sudo systemctl restart mysql.service
sudo mysql -u root -p
# https://linuxhint.com/change-mysql-password-ubuntu-22-04/#:~:text=To%20change%20the%20MySQL%20root%20password%20in%20Ubuntu%2022.04%2C%20firstly,to%20specify%20the%20new%20password.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment