How to change the user password of MySQL database
This article mainly shows you "how to change the MySQL database user password", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to change the MySQL database user password" this article.
One: directly use the mysqladmin command to modify the root user password
1): if the root user does not have a password,
Mysqladmin-u root password newpassword
2): if the root user already has a password,
Mysqladmin-u root-poldpassword password newpassword
Second, log in to the database to change the root password
The root user password is stored in the user of mysql in the mysql database and can be modified according to the following statement: (this modification method, the password is saved in plaintext, cannot be logged in, and the actual modification is invalid)
Update mysql.user set password='newpassword' where user='username'
Flush privileges
Third: the method of using set password
Set password for username@'localhost' = password ('newpassword')
Four: the method of using grant privileges
Grant all privileges on *. * to 'username'@'%' identified by' newpassword'
Flush privileges
Add: change root password when you forget root password
If you forget the root password, you can use the following methods to change the root password:
1): close the mysql database
2): start the mysql database by skipping permission detection
/ usr/local/mysql/bin/mysqld_safe-skip-grant-tables &
3): reset the root password
Set password for 'username'@'localhost' = password (' newpassword')
Flush privileges
4): close mysql and start mysql normally
The above is all the contents of the article "how to change the user password of MySQL database". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!