mysql create a read-only user tables in a database

1. Create a user and authorize the SELECT query authority, authorized remote access, attention, command username / password means the user name and password, please specify your own. To limit specifies only this user can use IP access Mysql, will be replaced with IP% can, dbname database specified limit, if at all will be replaced *.

GRANT SELECT ON dbname.* TO 'username'@'%' IDENTIFIED BY "password";

2. Refresh mysql privileges, allowing users to create, authorize force.

FLUSH PRIVILEGES;

operating privilege on behalf of select, update, insert, delete as well as stored procedures, functions, etc. can also be used to perform on behalf of all ALL.

------------------------------------------------
only check a database in a particular table (read only)
Grant the SELECT ON allindata_deb.user to lhz @% IDENTIFIED by 123456;
Grant the SELECT ON test.Test to the Test @% IDENTIFIED by 123456;

------------------------------------------------

Create a user

create user 'discuz'@'localhost' identified by 'discuz';

 

Change permissions user access to the database

grant all on discuz.* to 'discuz'@'localhost';

 

Change the permissions to change the use of non-native database user connection to the database

update mysql.user set host='%' where host='localhost';

grant all privileges on *.* to 'root'@'%' with grant option;

flush privileges;

 

Delete permissions

revoke privileges on databasename.tablename to 'username'@'host';

View Permissions

show grants;

 

Guess you like

Origin www.cnblogs.com/hiit/p/11301035.html