Home > Database > Mysql Tutorial > body text

How to set password in mysql without password

coldplay.xixi
Release: 2020-10-26 15:36:01
Original
8708 people have browsed it

Mysql password-less setting method: 1. Use mysqladmin to complete [shell> mysqladmin -u root password "newpwd"]; 2. Use the SET PASSWORD command in mysql to complete.

How to set password in mysql without password

Mysql passwordless method to set password:

Method one: The simplest The method is also the method prompted by the system after installing mysql. Use mysqladmin to complete.

shell> mysqladmin -u root password "newpwd"
Copy after login

shell> mysqladmin -u root -h host_name password "newpwd"The double quotation marks after password are not necessary, but if the password contains spaces or some special symbols, quotation marks are required.

Method 2: Use the SET PASSWORD command in mysql to complete. Note that the PASSWORD() function must be used to encrypt the set newpwd, otherwise directly ='newpwd' will not take effect. However, if you use method 1 to set the password with mysqladmin password or GRANT, you do not need to use the PASSWORD() function because they have automatically called this function. shell> mysql -u root

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');
Copy after login

Method 3:Set password directly through UPDATE user tableshell> mysql -u root

mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
-> WHERE User = 'root';
mysql> FLUSH PRIVILEGES;
Copy after login

Update More related free learning recommendations: mysql tutorial(video)

The above is the detailed content of How to set password in mysql without password. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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