Home >Database >Mysql Tutorial >How to change mysql password in linux
Under Linux system, we often need to change the Mysql database password. Mysql database is a very popular database management system and is widely used. Let's take a look at how to change the password of the Mysql database under the Linux system.
Step 1: Log in to Mysql
First, we need to log in to Mysql using the root account. Enter the following command in the terminal:
mysql -u root -p
After pressing the Enter key, the system will prompt you to enter the password of the root account. After entering the correct password, you can log in to the Mysql database.
Step 2: Change password
Once you have successfully logged in to the Mysql database, you can use the following command to change the Mysql password:
USE mysql; UPDATE user SET authentication_string=PASSWORD('New_password_here') WHERE User='root';
This command will change the root account's password The password is changed to New_password_here. After the modification is completed, you need to update your user permissions and exit Mysql.
FLUSH PRIVILEGES; QUIT;
Step 3: Verify the new password
Now, you can use the new password to log in to the Mysql database. Enter the following command in the terminal:
mysql -u root -p
When the password prompt appears, enter the new password. If you enter the correct password, you will be able to log in to the Mysql database. Congratulations, you have successfully changed the password of the Mysql database.
Notes
When changing the Mysql password under the Linux system, please pay attention to the following:
Summary
Now, you already know how to change the password of Mysql database under Linux system. This is very important because Mysql database is a popular database management system, and in During the operation, we need to change the password frequently to improve security. We hope you find these steps helpful so you can better manage your data.
The above is the detailed content of How to change mysql password in linux. For more information, please follow other related articles on the PHP Chinese website!