试了这个set global read_only = 1; 是把实例下所有的库都给锁了
也试个锁定库下的所有表 ,这个貌似是会话级的,对其他已连接的用户不起作用
lock table T1 read;
lock table T2 read;
lock table T3 read;
..............
set global read_only = 1; 是把实例下所有的库都给锁了lock table T1 read;
lock table T2 read;
lock table T3 read;
..............
1
yemoluo Mar 1, 2023
要 global
|
2
wps353 Mar 1, 2023
MySQL 8.0.22 以上的版本可以设置库级别的 read only.
"The READ ONLY option, introduced in MySQL 8.0.22, controls whether to permit modification of the database and objects within it. The permitted values are DEFAULT or 0 (not read only) and 1 (read only). This option is useful for database migration because a database for which READ ONLY is enabled can be migrated to another MySQL instance without concern that the database might be changed during the operation." |