mysql admin -u 用户名 -p 旧密码 passw 新密码
‘u’ is the abbreviation of username, and ‘p’ is the abbreviation of the original password.
We first log in to the MySQL database. Then enter:
mysql>set password for root@localhost = pasword('w3cschool');
or
mysql>SET PASSWORD = PASSWORD('w3cschool');
The password at this time has been changed to ‘w3cschool’.
If you want to set the password to empty, you need to write the following code:
mysql>set password for root@localhost = '';
or
mysql>SET PASSWORD = '';
At this time, the login password has been set to empty, we don’t need to Enter your password to log in directly.
The above is the detailed content of How to change the MySQL password in the MySQL command line. For more information, please follow other related articles on the PHP Chinese website!