Home  >  Article  >  Database  >  How to change the MySQL password in the MySQL command line

How to change the MySQL password in the MySQL command line

WBOY
WBOYforward
2023-05-26 22:37:121655browse

Method 1:

mysql admin -u 用户名 -p 旧密码 passw 新密码

‘u’ is the abbreviation of username, and ‘p’ is the abbreviation of the original password.

Method 2:

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete
Previous article:How to use mysql key lockNext article:How to use mysql key lock