How to change the mysql root User Password

Source: Internet
Author: User

Change the mysql password, mysql change the root password, how to change the mysql password, mysql change the User Password

First, we need to declare that, in most cases, modifying MySQL requires the root permission in mysql. Therefore, users cannot change the password unless they request the Administrator.

Method 1: Use phpmyadmin, which is the simplest. Modify the user table of the mysql database, but do not 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, enter the original root password and change the root password 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 is definitely adding a user, the user name is jeffrey and the password is biscuit. I wrote this example in mysql Chinese reference manual. Be sure to use the PASSWORD function, and then use flush privileges.

Method 4 is similar to method 3, but the REPLACE statement mysql> replace into mysql is used. 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 GRANT... identified by statement mysql> grant usage on *. * TO jeffrey @ "%" identified by 'biscuit'; the PASSWORD () function is unnecessary and does not need TO be flush privileges. Note: PASSWORD () [not] is stored in Unix Password Password Encryption is implemented in the same way as encryption.

 

Use mysql
Update user set Password = password ('newpassword') where User = 'root ';
Flush privileges;

1. Modify the USER table of the MYSQL database in the MYSQL database
You can use normal UPDATE and INSERT statements.

2. Use the following command in the command line:
MYSQLADMIN-u root-p PASSWORD mypasswd

3. You can modify the MY. ini file in the MYSQL folder.

4. Use the set password statement,
Mysql> set password for myuser @ localhost = PASSWORD ('mypasswd ');

5. Use the GRANT... identified by statement
Mysql> grant usage on *. * TO myuser @ localhost identified by 'mypassw

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.