MySQL Licensing issues Summary _php skills

Source: Internet
Author: User
Tags flush
I use localhost root account can not even ask the DBA group to finalize the new user!

Now get some information for the authorized user for a rainy

Examples of Authorization table usage

Grant is used to add users and create permissions, revoke to remove user permissions.

Here are some examples of adding users and creating permissions with Grant:

Mysql> grant all privileges in *.* to test@localhost identified by ' Test ' with GRANT option;

This sentence adds a test user (Superuser) with all permissions locally, and the password is test. The *.* in the ON clause means "all databases, all tables." The WITH GRANT option indicates that it has grant permissions.

Mysql> Grant Select,insert,update,delete,create,drop privileges on test.* to test1@ ' 192.168.1.0/255.255.255.0 ' Identified by ' Test ';

This sentence is added to a test1 user, password is test, but it can only be 192.168.1 from the C-class subnet connection, the test library has select,insert,update,delete,create,drop operation permissions.

Creating permissions with the GRANT statement does not require a manual refresh of the authorization table because it has been refreshed automatically.

Creating permissions for users can also be done by directly modifying the authorization table:

mysql> INSERT INTO user

VALUES ("localhost", "Test", Password ("test"), "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y";

mysql> flush Privileges;

These two sentences are the same as the one in the first sentence of Grant, and add a local test super user. We see a lot more convenient with grant, and we don't need flush privileges.

mysql> INSERT INTO User (Host,user,password) VALUES ("192.168.1.0/255.255.255.0", "Test1", Password ("test")); Mysql> INSERT into DB values ("192.168.1.0/255.255.255.0", "Test", "Test1", "Y", "Y", "Y", "Y", "Y", "Y", "n", "n", "n", "n" ) mysql> flush privileges;

These three sentences are the same as those of Grant in the second sentence, adding a test1 user who can only connect from the C-class subnet 192.168.1 to the test library with select,insert,update,delete,create,drop operation rights. The password is test. To cancel the permissions of one user, use the REVOKE statement. The syntax for revoke is very similar to the grant statement, except to replace it with and without the identified by and with GRANT OPTION clauses, the following is an example of removing user rights with revoke:

Mysql> revoke all in test.* from test1@ ' 192.168.1.0/255.255.255.0 ';

This revoke the second sentence granted by Grant, but the Test1 user is not deleted and must be deleted manually from the user table:

mysql> Delete from user where user= ' test1 ';

mysql> flush Privileges;

In this way, the Test1 user is completely deleted.

These are just the simple use of the MySQL authorization form, please see the manual provided by MySQL for more detailed information.
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.