Home > Database > Mysql Tutorial > body text

How to change mysql password

藏色散人
Release: 2019-06-01 11:06:16
Original
32715 people have browsed it

How to change mysql password

How to change mysql password?

How to modify the mysql password:

Method 1: Use the SET PASSWORD command

First log in to MySQL.

Format: mysql> set password for username@localhost = password('new password');

Example: mysql> set password for root@localhost = password('123');

Method 2: Use mysqladmin

Format: mysqladmin -u username -p old password password new password

Example: mysqladmin -uroot -p123456 password 123

Method 3: Use UPDATE to directly edit the user table

First log in to MySQL.

mysql> use mysql;  
mysql> update user set password=password('123') where user='root' and host='localhost';  
 
mysql> flush privileges;
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!