Use the mysqladmin command to modify the MySQL password and forgot password

Source: Internet
Author: User
Tags mysql in phpmyadmin

Change Password:

1. For example, your root user does not now have a password and you want the password to be changed to 123456, then the command is:

Mysqladmin-u Root Password 123456

2. If your root now has a password (123456), then the command to change the password to ABCdef is:

Mysqladmin-u root-p Password abcdef

Note that the command will ask you the old password, enter the old password 123456 after the command completes, the password modification succeeds.

3. If your root now has a password (123456), then the command to change the password to ABCdef is:

Mysqladmin-u root-p123456 Password abcdef (note-p do not and the following password points

Write, write together, or it will go wrong, the error is as follows)

4. Using phpMyAdmin, this is the simplest, modify the MySQL library's user table,


But don't forget to use the password function.



Forgot Password:

Below we provide 6 different ways to modify the MySQL root user's password, with the addition of MySQL users.

Method One

Using phpMyAdmin, this is the simplest, modify the MySQL library's user table,

But don't forget to use the password function.

Method Two

Using Mysqladmin, this is a special case of the preceding declaration.

Mysqladmin-u root-p Password mypasswd

After entering this command, you need to enter the root's original password, then the root password will be changed to MYPASSWD.

Change the root of the command to your username, and you can change your own password.

Of course if your mysqladmin is not connected to MySQL server, or you have no way to execute mysqladmin,

Then this method is ineffective.

And mysqladmin can't erase the password.

The following methods are used at the MySQL prompt and must have root privileges for MySQL:

Method Three

Mysql> INSERT into Mysql.user (Host,user,password)

VALUES ('% ', ' Jeffrey ', PASSWORD (' biscuit '));

Mysql> FLUSH Privileges

Specifically, this is the addition of a user named Jeffrey, with a password of biscuit.

There is this example in the MySQL Chinese reference manual, so I wrote it out.

Note that you want to use the password function, and then you also use the flush privileges.

Method Four

As with method Three, just use the Replace statement

Mysql> REPLACE into Mysql.user (Host,user,password)

VALUES ('% ', ' Jeffrey ', PASSWORD (' biscuit '));

Mysql> FLUSH Privileges

Method Five

Using the Set Password statement,

mysql> SET PASSWORD for [email protected] "%" = PASSWORD (' biscuit ');

The password () function must also be used,

However, you do not need to use flush privileges.

Method Six

Use Grant ... Identified by statement

Mysql> GRANT USAGE On * * to [e-mail protected] "%" identified by ' biscuit ';

Here the password () function is unnecessary and does not require the use of flush privileges.

Note: PASSWORD () [NOT] Execute password encryption in the same way that the UNIX password is encrypted.

MySQL Forgot Password Solution

If MySQL is running, first kill it: Killall-term mysqld.

Start Mysql:bin/safe_mysqld--skip-grant-tables &

You can go to MySQL without a password.

Then there is

>use MySQL

>update User Set Password=password ("New_pass") where user= "root";

>flush privileges;

Kill MySQL again and start MySQL in a normal way.




Use the mysqladmin command to modify the MySQL password and forgot password

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.