Summary of six measures for changing the MySQL password in the MySQL database

Source: Internet
Author: User

MySQL database, We sometimes needModify MySQL passwordTo ensure database security. There are usually many ways to change the password, and it is easy to implement. This article summarizes six methods to change the MySQL password. These six methods can be implemented only when the MySQL database has the ROOT permission. Next we will introduce these six measures.

Measure 1:Phpmyadmin is the easiest way to fix the user table in the mysql database. Do not forget to use the PASSWORD function.

Measure 2:Use mysqladmin, which is a special case stated above. Mysqladmin-u root-p password mypasswd after entering this call, you must enter the original root password, and then change the root password to mypasswd. Change the root user name in the call to your username, and you will be able to change your password. Of course, in case your mysqladmin cannot connect to the mysql server, you may not have taken any measures to enforce mysqladmin, even if this measure is ineffective. In addition, mysqladmin cannot clear the password.

Note: The following measures are used in the mysql reminder, and the root permission of mysqlkcitrust.com must be available:

Measure 3:

 
 
  1. mysql> INSERT INTO mysql.user (Host,User,Password) VALUES('%','jeffrey',PASSWORD('biscuit'));   
  2.  
  3. mysql> FLUSH PRIVILEGES 

Accurately speaking, this is an additional user, with the username jeffrey and password biscuit. I wrote this example in mysql Chinese reference manual. Be careful to use the PASSWORD function, and then use flush privileges.

Measure 4:The REPLACE statement is used

 
 
  1. mysql> REPLACE INTO mysql.user (Host,User,Password) VALUES('%','jeffrey',PASSWORD('biscuit'));   
  2.  
  3. mysql> FLUSH PRIVILEGES 

Measure 5:Use the set password statement

 
 
  1. mysql> SET PASSWORD FOR jeffrey@"%" = PASSWORD('biscuit');  

You must also use the PASSWORD () function, but you do not need to use flush privileges.

Measure 6:Use the GRANT... identified by statement

 
 
  1. mysql> GRANT USAGE ON *.* TO jeffrey@"%" IDENTIFIED BY 'biscuit';  

Here, the PASSWORD () function is not required, and you do not need to use flush privileges.

Note: PASSWORD () is not encrypted using the same measures as the Unix PASSWORD.

Here is an overview of the MySQL database's measures to correct the MySQL password. If you want to learn more about the MySQL database, please refer to the article http://database.51cto.com/mysql/, which will surely bring you the opportunity.

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.