Specifically about the role of the WITH GRANT option in MySQL licensing

Source: Internet
Author: User

The owner of the object assigns permissions to a user (for example: TestUser1)

Grant SELECT, update on Bd_corp to TestUser1 [with GRANT OPTION]
1. If you have with GRANT option
Then user testuser1 can pass Select, update permissions to other users (such as TestUser2)
Grant Select,update on Bd_corp to TestUser2
2. If you do not have with GRANT option
Then user testuser1 cannot give TestUser2 authorization

The simple thing is to pass permissions to third parties.

~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~

Examples of use of authorization forms

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

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

Mysql> Grant all privileges on * * to [e-mail protected] identified by ' Test ' with GRANT option;

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

Mysql> Grant Select,insert,update,delete,create,drop privileges on test.* to [email protected] ' 192.168.1.0/ 255.255.255.0 ' identified by ' test ';

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

Creating a permission with the GRANT statement does not require a manual refresh of the authorization table because it is automatically refreshed.

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 first one above and add a local test super user. We see more convenience with Grant, and we don't need to 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 and the second sentence above Grant's effect is also the same, also added a can only from the Class C subnet 192.168.1 connection, the test library has select,insert,update,delete,create,drop operation rights of Test1 users, The password is test. To remove a user's permissions, use the REVOKE statement. The syntax of the revoke is very similar to the grant statement, except that to is substituted by and without the identified by and with GRANT OPTION clauses, the following is an example of removing a user right with revoke:

Mysql> revoke all on test.* from [email protected] ' 192.168.1.0/255.255.255.0 ';

This revoke the second sentence of grant creation permission, but the test1 user is not deleted and must be removed manually from the user table:

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

mysql> flush Privileges;

In this way, the test1 user is completely removed.

Specifically about the role of the WITH GRANT option in MySQL licensing

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.