The set global read_only is a global level and can be written by the root user after 1, and other users cannot write FLUSH tables with read lock is table-level (using unlock tables to unlock) and cannot be written by all users after execution. But after flush tables, the lock fails, and the set global READ_ONLY does not fail
Set global read_only=true or set global Read_only=on or set global Read_only=1
Set global Read_only=false or set global Read_only=off or set global read_only=0
1:select @ @read_only \g
->@ @read_only: 0
1:create TABLE IF not EXISTS bla (id BIGINT (), PRIMARY KEY (id));
1:lock TABLE bla READ;
2:set Global read_only=0;
->will block until the lock from Connection 1 is released.
1:unlock TABLES;
2:set Global Read_only=1;
1:select @ @read_only \g
->@ @read_only: 1
1:lock TABLE bla read;
2:set Global Read_only=1;
->will block until the lock from Connection 1 is released.
1:unlock TABLES;
1:select @ @read_only \g
->@ @read_only: 1
1:lock TABLE bla read;
2:set Global read_only=0;
->will block until the lock from Connection 1 is released.