Play MySQL Licensing

Source: Internet
Author: User
Tags mysql create

0. Delete the system surplus account
Use MySQL;
Select User,host from Mysql.user;
Delete from user where user= ';
Flush privileges;

MySQL Create account:
mysqladmin-u root password ' 123456 '

Take the demo library test library, respectively demo_1 and test_1 table for example:
Create database demo;

CREATE TABLE demo_1 (id int);
INSERT into Demo_1 (ID) VALUES (1), (2), (3);

Create DATABASE test;
CREATE TABLE test_1 (id int);
INSERT into test_1 (ID) VALUES (1), (2), (3);

CREATE TABLE test_2 (id int);
INSERT into test_2 (ID) VALUES (1), (2), (3);

1. Authorize all libraries
Create a new user and authorize, and the password is blank: Grant all on *. * to [email protected] ' localhost '

Create a new user and authorize and set a password: Grant all on * * to [email protected] ' localhost ' identified by ' 123456 ';
Or grant SELECT, INSERT, UPDATE, delete on *. * to [email protected] ' localhost '

Refresh permissions: Flush privileges;

View permissions: Show grants for [email protected] ' localhost ';
GRANT all privileges on * * to ' test ' @ ' localhost ' identified by PASSWORD ' *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 '

Test permissions (yes): Mysql-utest-p123456-e ' select * from Demo.demo_1 ';

1.1 Revoke permissions
REVOKE permission: Revoke all on * * from [email protected] ' localhost ';

Refresh permissions: Flush privileges;

View permissions: Show grants for [email protected] ' localhost ';
GRANT USAGE on * * to ' test ' @ ' localhost ' identified by PASSWORD ' *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 '

Test permissions (not available): Mysql-utest-p123456-e ' select * from Demo.demo_1 ';
ERROR 1142 (42000) at line 1:select command denied to user ' test ' @ ' localhost ' for table ' Demo_1 '

2. Authorizing the specified library (one or more libraries)
Grant all on test.* to [email protected] ' localhost ';
Grant all on demo.* to [email protected] ' localhost ';
Note: You cannot authorize multiple libraries specified at one time, only one authorization: Grant all on test.*,demo.* to [email protected] ' localhost ';

View permissions: Show grants for [email protected] ' localhost ';
GRANT USAGE on * * to ' test ' @ ' localhost ' identified by PASSWORD ' *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 '

GRANT all privileges the ' test '. * to ' test ' @ ' localhost '
GRANT All Privileges "Demo". * to ' test ' @ ' localhost '

Test permissions (yes): Mysql-utest-p123456-e ' select * from Demo.demo_1 ';

2.1 Revoke Permissions
Revoke all on test.* from [email protected] ' localhost ';
Revoke all on demo.* from [email protected] ' localhost ';
Flush privileges;

Test permissions: Mysql-utest-p123456-e ' select * from Demo.demo_1 ';
ERROR 1142 (42000) at line 1:select command denied to user ' test ' @ ' localhost ' for table ' Demo_1 '
3. Authorized designated library (1 or more tables)
Authorization: Grant all on test.test_2 to [email protected] ' localhost ';
Refresh permissions: Flush privileges;
View permissions: Show grants for [email protected] ' localhost ';
GRANT USAGE on * * to ' test ' @ ' localhost ' identified by PASSWORD ' *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 '
GRANT all privileges in ' test '. ' test_2 ' to ' test ' @ ' localhost '
Test permissions: Mysql-utest-p123456-e ' select * from test.test_1 ';
ERROR 1142 (42000) at line 1:select command denied to user ' test ' @ ' localhost ' for table ' test_1 '
Mysql-utest-p123456-e ' select * from Test.test_2 '; Query there's something

Note: Authorizing a nonexistent table can also be successful, and you can also view the permissions.
3.1 Revoke permissions
Revoke all on test.test_2 from [email protected] ' localhost ';
Flush privileges;

4. Hide library does not allow authorization
Information_schema This library stores MySQL metadata such as database name or table name, column data type, or access permissions, etc.
Mysql

5. Accessing the database with the IP integer domain name
192.168.11.17 www.db.com
Navcat can be directly filled in the domain name, specify the port, you need to be aware that the host is the right to control access%/192.168.11.%/ 192.168.11.18/, wait.

This article from the "Development and operation of the" blog, declined to reprint!

Play MySQL Licensing

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.