Skip to content

Instantly share code, notes, and snippets.

@taynguyen
Created May 29, 2020 08:35
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 taynguyen/5862c8256ebb201c5b8147e29ad342f8 to your computer and use it in GitHub Desktop.
Save taynguyen/5862c8256ebb201c5b8147e29ad342f8 to your computer and use it in GitHub Desktop.
Update root password and allow login via password on MySQL

Situation:

  • You just installed MySQL (I'm worked with 5.70) on linux machine. You want to chagne root password and want to use password to login instead of login via sudo.

Actions

  • Login to mysql as root
sudo mysql -u root
  • Execute:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<your_password>';

This command will:

  • IDENTIFIED WITH mysql_native_password : Allow you to login via password. (But you won't be able to login by sudo)
  • Change root password to <your_password>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment