Home  >  Article  >  Database  >  mysql centos change password

mysql centos change password

WBOY
WBOYOriginal
2023-05-20 11:55:081352browse

MySQL is a popular relational database management system, and CentOS is a commonly used Linux server operating system. When you need to change the MySQL password on CentOS, you can follow the steps below.

Step 1. Log in to the MySQL server

You must first log in to the MySQL server as the Root user. You can log in using the following command:

$ mysql -u root -p

You will be asked to provide the password of the Root user, and then the MySQL console will be opened.

Step 2. Select the user whose password you want to change

Once you are logged in to the MySQL server, you can select the user whose password you want to change. You can list the current users using the following command:

mysql> SELECT user, host FROM mysql.user;

Select the user whose password you want to change from the list and record its username and host. Then select that user using the following command:

mysql> USE mysql;
mysql> ALTER USER 'user'@'host' IDENTIFIED BY 'new_password';

Note to replace "user" and "host" with the actual username and host of the user you selected, and "new_password" with the new password of your choice.

Step 3. Restart the MySQL server

After completing the password change, you need to restart the MySQL server for the new password to take effect. The MySQL server can be restarted using the following command:

$ systemctl restart mysqld

Step 4. Verify the new password

After restarting the MySQL server, log in with the new password and verify that it is valid. You can log in using the following command:

$ mysql -u user -p

Enter the actual username and new password of the previously selected user. If logged in successfully, you will be able to access the MySQL command line prompt and execute database commands.

Conclusion

Changing MySQL password is an easy task, just follow the simple steps above. You can use a similar process to change your MySQL password whether you are running on the CentOS operating system or not. Make sure your new password is strong enough to keep your system secure.

The above is the detailed content of mysql centos change password. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn