To prevent users from inserting from the library, use the Read-only parameter:
Configuration:
[Root@slave-mysql data]# grep read-only/etc/my.cnf
read-only
Test process:
Master Library Licensing All
Mysql> Grant all on *.* to ' imbyrd ' @ ' localhost ' identified by ' admin ';
Test from library:
[Root@slave-mysql data]#/usr/local/mysql/bin/mysql-uimbyrd-p ' admin '
mysql> use hitest;
mysql> INSERT INTO Test (id,name) VALUES (' fo ');
Query OK, 1 row affected (0.14 sec)
Master Library Authorization Select,insert,update,delete
Mysql> REVOKE all in *.* from ' imbyrd ' @ ' localhost ';
Mysql> Grant Select,insert,update,delete on *.* to ' imbyrd ' @ ' localhost ' identified by ' admin ';
Mysql> Show grants for imbyrd@ ' localhost ';
+-------------------------------------------------------------------------------------------------------------- --------------------------+
| Grants for Imbyrd@localhost |
+-------------------------------------------------------------------------------------------------------------- --------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE on *.* to ' imbyrd ' @ ' localhost ' identified by PASSWORD ' *4acfe3202a5ff5cf467898fc58aab 1d615029441 ' |
+-------------------------------------------------------------------------------------------------------------- --------------------------+
1 row in Set (0.00 sec)
Test from library:
mysql> use hitest;
mysql> INSERT INTO Test (id,name) VALUES (' dddd ');
ERROR 1290 (HY000): The MySQL server is running with the--read-only option so it cannot execute this statement
Main Library configuration:
Mysql> Grant all on *.* to ' imbyrd ' @ ' localhost ' identified by ' admin ';
Mysql> Show grants for imbyrd@ ' localhost ' \g
1. Row ***************************
Grants for imbyrd@localhost:grant all privileges on *.* to ' imbyrd ' @ ' localhost ' identified by PASSWORD ' *4ACFE3202A5FF5CF 467898fc58aab1d615029441 '
1 row in Set (0.00 sec)
Mysql> REVOKE SUPER on *.* from ' imbyrd ' @ ' localhost ';
Mysql> Show grants for imbyrd@ ' localhost ' \g
1. Row ***************************
Grants for Imbyrd@localhost:grant SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, Referenc ES, INDEX, ALTER, show DATABASES, CREATE temporary tables, LOCK tables, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CR Eate view, show view, create routine, ALTER routine, create USER, EVENT, TRIGGER, create tablespace on *.* to ' Imbyrd ' @ ' lo Calhost ' identified by PASSWORD ' *4acfe3202a5ff5cf467898fc58aab1d615029441 '
1 row in Set (0.00 sec)
Test from library:
[Root@slave-mysql data]#/usr/local/mysql/bin/mysql-uimbyrd-p ' admin '
mysql> use hitest;
mysql> INSERT INTO Test (id,name) VALUES (' Fddf ');
ERROR 1290 (HY000): The MySQL server is running with the--read-only option so it cannot execute this statement
conclusion : When the user does not have the Super privilege (all permission includes Super), the read-only from the library takes effect!