mysql 不能锁单个库?

2023-03-01 10:28:42 +08:00
 vopsoft

试了这个set global read_only = 1; 是把实例下所有的库都给锁了

也试个锁定库下的所有表 ,这个貌似是会话级的,对其他已连接的用户不起作用

lock table T1 read;
lock table T2 read;
lock table T3 read;
..............
1189 次点击
所在节点    MySQL
3 条回复
GTim
2023-03-01 10:30:16 +08:00
要 global
wps353
2023-03-01 10:42:50 +08:00
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."
vopsoft
2023-03-01 10:58:44 +08:00
@wps353 感谢解答

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/920076

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX