Home  >  Article  >  Database  >  mysql change user password

mysql change user password

PHPz
PHPzOriginal
2023-05-23 10:43:071055browse

MySQL is a popular relational database management system. An important aspect of managing DBMS is to protect the security of data tables and other objects. In MySQL, creating a user is relatively simple, but changing a user's password requires following certain steps. Let's take a closer look at how to change a user's password in MySQL.

  1. Login to MySQL
    After installing mysql, a MySQL client will come with it. If you need to change the user password, you need to enter the MySQL client and enter the following command to log in:

mysql -u root -p

When we run the above command, we will be asked to enter the password of the MySQL root user. After entering it, you can enter MySQL.

  1. Use the following command to change the user password statement:

mysql> UPDATE user SET Password=PASSWORD('new_password') WHERE user='user_name';

The name of the user who needs to change the password is "user_name", and his new password is "new_password". When we run this command, the user's password is changed.

  1. Refresh the database to make the changes take effect
    When using the password change operation, you need to reload the permissions (or permissions) in the database and refresh the cache so that the changes can be reflected in MySQL Take effect. We can use the following command to refresh MySQL:

mysql> FLUSH PRIVILEGES;

This command reloads the database permission and refreshes the cache, so You can also make password changes take effect.

  1. End of execution
    After the above three steps, we can exit the MySQL client. To exit, use the following command:

##mysql> quit ;

When we successfully complete the above command, we can change the password of the specified MySQL user.

Summary:

MySQL is an excellent relational database management system. When allowing user password changes, we need to operate them one by one. After the changes are completed, we need to refresh the database. We have all these details. Need to master. When we operate these steps very skillfully, it will definitely have a good effect on our MySQL management and maintenance.

The above is the detailed content of mysql change user 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
Previous article:mysql query orderNext article:mysql query order