Home >Database >Mysql Tutorial >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!