Change a Password for MySQL on Linux via Command Line
- Change a Password for MySQL on Linux via Command Line
- Create a MySQL Database on Linux via Command Line
- Select a MySQL Database on Linux via Command Line
- How to Delete a Database in MySQL/MariaDB
- How to Backup and Restore MySQL Databases from the Command Line
MySQL via Command Line 102: Basic User Interaction
- 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 log in to the MySQL server from the command line with the following command:
mysql -u root -p
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:
use mysql;
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:
update user set password=PASSWORD('your_new_password') where User='root';
Finally, reload the privileges:
flush privileges;
Now you're all set to exit MySQL!
quit
Related Articles:
About the Author: Justin Palmer
Justin Palmer is a professional application developer with Liquid Web
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
How to Clone a Drupal Site to Another Domain
Read ArticleTop Eight Virtualization Security Issues and Risks
Read ArticleAccessing Man Pages on Ubuntu 16.04 LTS
Read ArticlePremium Business Email Pricing FAQ
Read ArticleMicrosoft Exchange Server Security Update
Read Article