Summary of several common methods for changing MYSQL passwords

Source: Internet
Author: User

First, we need to declare that, in most cases, modifying MySQL requires the root permission in mysql.
Therefore, you cannot change the password unless you request the Administrator. ­
­
Method 1
Phpmyadmin is the simplest. Modify the user table of the mysql database.
But don't forget to use the PASSWORD function. ­
­
Method 2
Use mysqladmin, which is a special case stated above. ­
Mysqladmin-u root-p password mypasswd
After entering this command, you need to enter the original root password, and then the root password will be changed to mypasswd. ­
Change the root in the command to your username, and you can change your password. ­
Of course, if your mysqladmin cannot connect to mysql server, or you cannot execute mysqladmin
This method is invalid. ­
In addition, mysqladmin cannot clear the password. ­
­
The following methods are used at the mysql prompt and must have the root permission of mysql:
Method 3
Mysql> insert into mysql. user (Host, User, Password) ­
VALUES ('%', 'Jeffrey ', PASSWORD ('biscuit');
Mysql> FLUSH PRIVILEGES
Specifically, this is adding a user with the username jeffrey and password biscuit. ­
I wrote this example in mysql Chinese reference manual. ­
Be sure to use the PASSWORD function, and then use flush privileges. ­
­
Method 4
Similar to method Sany, but the REPLACE statement is used.
Mysql> replace into mysql. user (Host, User, Password) ­
VALUES ('%', 'Jeffrey ', PASSWORD ('biscuit');
Mysql> FLUSH PRIVILEGES
­
Method 5
Use the set password statement.
Mysql> set password for jeffrey @ "%" = PASSWORD ('biscuit ');
You must also use the PASSWORD () function.
However, you do not need to use flush privileges. ­
­
Method 6
Use the GRANT... identified by statement.
Mysql> grant usage on *. * TO jeffrey @ "%" identified by 'biscuit ';
Here, the PASSWORD () function is unnecessary and does not need to be flush privileges. ­
­
Note: PASSWORD () [not] implements PASSWORD encryption in the same way as Unix PASSWORD encryption. ­
How to fix MySQL password loss
If MySQL is running, killall-TERM mysqld is first killed. ­
Start MySQL: bin/safe_mysqld -- skip-grant-tables & ­
You can access MySQL without a password. ­
Then
> Use mysql
> Update user set password = password ("new_pass") where user = "root"; ­
> Flush privileges; ­
Kill MySQL again and start MySQL in a normal way. ­
­
Note: you must use the encryption method when using phpmyadmin to change the password. Otherwise, you cannot enter phpmyadmin after modification! ­
We recommend that you use the command line to change the password.
After entering mysql
Mysql> update mysql. user set password = password ('new password ');
Mysql> flush privileges;
If you cannot log on to phpmyadmin after using phpmyadmin to change the password, the simplest way is to reinstall phpmyadmin. You only need to delete the original phpmyadmin folder and decompress the phpmyadmin compressed package again, this method is a rare trick I think of when I try every means to change my password and cannot log on ...... ­

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.