In MySQL modify password and access restrictions set the details

Source: Internet
Author: User
Tags flush require mysql database

MySQL is a real multi-user, multi-threaded SQL database server. MySQL is implemented as a client/server architecture, consisting of a server daemon mysqld and many different client programs and libraries. Because of its open source and stability, and with the perfect combination of PHP, now many sites are used as a back-end database, so that it has been widely used. Security considerations require that each user be assigned access restrictions to different databases to meet the requirements of different users. The following is discussed separately for your reference.

A, MySQL modified password method summary

The first thing to say is: Under normal circumstances, to modify the MySQL password is required to have the root of MySQL, so the average user can not change the password, unless the administrator to help modify.

Method One

Using phpMyAdmin

(graphical management of MySQL database Tools), this is the simplest, directly with SQL statements to modify the MySQL Database Library user table, but do not forget to use the password function, insert the user with the Insert command, modify the user with the update command, delete the deletion with the delete command. A detailed description of the data table User field is available later in this section.

Method Two

Use Mysqladmin. Input

mysqladmin -u root -p oldpassword newpasswd

After executing this command, you need to enter the original password of root, so that the root password will be changed to NEWPASSWD. Again, 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 invalid, and mysqladmin cannot empty the password.

The following methods are used at the MySQL prompt and must have the root permissions of MySQL:

Method Three
mysql> INSERT INTO mysql.user (Host,User,Password) VALUES
('%','system', PASSWORD('manager'));
mysql> FLUSH PRIVILEGES

Specifically, this is adding a user named system with a password of manager. Note that you want to use the password function, and then use flush privileges to perform the validation.

Method Four

And method Three, just use the Replace statement

mysql> REPLACE INTO mysql.user (Host,User,Password)
VALUES('%','system',PASSWORD('manager'));
mysql> FLUSH PRIVILEGES

Method Five

Using the Set Password statement

mysql> SET PASSWORD FOR system@"%" = PASSWORD('manager');

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

Method Six

Use Grant ... Identified by statement to authorize.

mysql> GRANT USAGE ON *.* TO system@"%" IDENTIFIED BY 'manager';

This password () function is unnecessary and does not require the use of flush privileges to perform validation.

Note: PASSWORD () function is to encrypt password, in the program MySQL automatic interpretation.

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.