MySQL Database Modify password method

Source: Internet
Author: User
Tags flush phpmyadmin

Method One:

(for administrators or users with global permissions to reset another user's password)
Enter command line mode
Mysql-u Root MySQL
mysql> UPDATE user SET Password=password ("New password") WHERE user= ' name ';
mysql> FLUSH privileges;
Mysql> QUIT


Method Two:
(Apply ditto, just different method)
Mysql-u Root MySQL
Mysql> SET PASSWORD for Name=password (' New PASSWORD ');
Mysql> QUIT


(These two methods I am not commonly used, if the administrator, I will use other tools such as phpMyAdmin or mysql-front to manage user rights, more intuitive and convenient)


Method Three
using phpMyAdmin, this is the easiest, to modify the MySQL library's user table,
But don't forget to use the password function.

Method Four

Using Mysqladmin, this is a special case of the previous declaration.
Mysqladmin-u root-p Password mypasswd
After entering this command, you need to enter the original password for root, and then the root password will be changed to MYPASSWD.
Change the command root to your username, and you can change your 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 empty the password.
The following methods are used at the MySQL prompt and must have the root permissions of MySQL:

Method Five

Mysql> INSERT into Mysql.user (Host,user,password) VALUES ('% ', ' Jeffrey ', Password (' biscuit '));
Mysql> FLUSH Privileges
To be exact, this is adding a user, the username is Jeffrey, and the password is biscuit.
Note that you want to use the password function, and then use flush privileges.

Method Six

And method Three, just use the Replace statement
Mysql> REPLACE into Mysql.user (Host,user,password)
VALUES (%,jeffrey,password (iscuit));
Mysql> FLUSH Privileges

Method Seven
using the Set password statement,
Mysql> SET PASSWORD for jeffrey@ "%" = PASSWORD (Iscuit);
You must also use the password () function,
But you don't need to use flush privileges.


Method Eight

Use Grant ... Identified by statement
Mysql> GRANT USAGE on *.* to jeffrey@ "%" identified by Iscuit;
Here the password () function is unnecessary and does not require the use of flush privileges.

There are many ways to do it, but ultimately that is the kind of command executed here.

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.