Pre-Flight Check
- These instructions are intended for setting the password for all MySQL users named root on Linux via the command line. However, they can also be followed to change the password for any MySQL user.
- I’ll be working from a Liquid Web Core Managed CentOS 6.5 server, and I’ll be logged in as root.
First we’ll login to the MySQL server from the command line with the following command:
In this case, I’ve specified the user root with the -u flag, and then used the -p flag so MySQL prompts for a password. Enter your current password to complete the login.
Now switch to the appropriate MySQL database with the following command:
Next we’ll update the password for all MySQL users with the name root. Be sure to replace your_new_password with the actual new password:
Mã:
update user set password=PASSWORD('your_new_password') where User='root';
Note: You can change the password for any user with the above command. Simply specify that user’s username in place of root.
Finally, reload the privileges:
Now you’re all set to exit MySQL!