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?
How to change the root's password in Linux environment?
After trying many approaches, the following steps work with me:
- Use sudo to log in mysql as root without needing a password:
sudo mysql -u root
- Update the user table, i.e.,
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';
- Restart the service:
sudo service mysql restart
Approaches I had tried
Approaches I had tried
The following lists approaches I had tried, which didn't work with me. However, you may try as they may work on your machines:
- https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
- https://www.a2hosting.com/kb/developer-corner/mysql/reset-mysql-root-password
- https://www.techrepublic.com/article/how-to-set-change-and-recover-a-mysql-root-password/
- https://support.rackspace.com/how-to/mysql-resetting-a-lost-mysql-root-password/
- https://stackoverflow.com/questions/7534056/mysql-root-password-change
- https://support.rackspace.com/how-to/mysql-resetting-a-lost-mysql-root-password/
Of course, the solution may differ from MySQL versions to versions.
References
References
This tutorial is summarized and is revised from:
Other blogged posts >> Tutorials