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

How to change the MySQL password in the MySQL command line

WBOY
Release: 2023-05-26 22:37:12
forward
1672 people have browsed it

Method 1:

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

‘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');
Copy after login

or

mysql>SET PASSWORD = PASSWORD('w3cschool');
Copy after login

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 = '';
Copy after login

or

mysql>SET PASSWORD = '';
Copy after login

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!

Related labels:
source:yisu.com
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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template