MySQL Privilege Management

1. Create a user

GRANT

{

SELECT, UPDATE, DELETE, INSERT (permission), ALL (representing all privileges)

}

ON database.table to 'username'@'host IP' identified by 'password';

FOR EXAMPLE:

GRANT SELECT ON  testdb.testtable TO 'user'@'%' identified by '123456';

Create a user named user with a password of 123456. All IPs can log in with this username and password, and have the SELECT query permission on the testtable table of the testdb database;

2. View permissions

show  grants for user;


Notice:

In general, this is enough, you can read all table data in the database, modify and insert data into the specified database table;

Sometimes you may find that you have authorized and refreshed the permissions, but your permissions do not seem to be successful, so you should use the following tricks, and then you can!

The trick below:


show  variables like 'read_only';

If found to be ON, change to OFF

set GLOBAL read_only = OFF;

flush privileges;

In this way, it is found that the permissions set before can work;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325773023&siteId=291194637