Home >Database >Mysql Tutorial >How to change mysql password

How to change mysql password

藏色散人
藏色散人Original
2019-06-01 11:06:1632930browse

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;

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!

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:What is mysql slow queryNext article:What is mysql slow query