V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
vopsoft
V2EX  ›  MySQL

mysql 不能锁单个库?

  •  
  •   vopsoft · Mar 1, 2023 · 1811 views
    This topic created in 1159 days ago, the information mentioned may be changed or developed.

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

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

    lock table T1 read;
    lock table T2 read;
    lock table T3 read;
    ..............
    
    3 replies    2023-03-01 10:58:44 +08:00
    yemoluo
        1
    yemoluo  
       Mar 1, 2023
    要 global
    wps353
        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."
    vopsoft
        3
    vopsoft  
    OP
       Mar 1, 2023
    @wps353 感谢解答
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2472 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 08:43 · PVG 16:43 · LAX 01:43 · JFK 04:43
    ♥ Do have faith in what you're doing.