Changing MySQL root's password

This is supposed to be a concise tutorial and you should not spend longer than 10 minutes to go through it.

How to change the root's password in Linux environment?

After trying many approaches, the following steps work with me:

  1. Use sudo to log in mysql as root without needing a password: sudo mysql -u root
  2. Update the user table, i.e., ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';
  3. Restart the service: sudo service mysql restart

References

This tutorial is summarized and is revised from:

Other blogged posts >> Tutorials