MySQL from the library read-only configuration detailed

Source: Internet
Author: User

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!

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.