当前位置:
MySQL设置数据库为只读
时间:2025-11-04 08:19:21 出处:应用开发阅读(143)

复制# 查看 read_only 参数 mysql> show global variables like%read_only%; +-----------------------+-------+ | Variable_name | Value | +-----------------------+-------+ | innodb_read_only | OFF | | read_only | OFF | | super_read_only | OFF | | transaction_read_only | OFF | | tx_read_only | OFF | +-----------------------+-------+ # 动态修改 read_only 参数 (若想重启生效 则需将 read_only = 1 加入配置文件中) mysql> setglobal read_only = 1; Query OK,置数 0 rows affected (0.00 sec) mysql> show global variables likeread_only; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | read_only | ON | +---------------+-------+ # read_only 开启的情况下 操作数据 # 使用超级权限用户 mysql> createtable tb_a (a int); Query OK, 0 rows affected (0.05 sec) # 使用普通权限用户 mysql> createtable tb_b (b int); ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement # 开启 super_read_only,b2b信息网再次使用超级权限用户来操作数据 mysql> setglobal super_read_only = 1; Query OK,据库 0 rows affected (0.00 sec) mysql> show global variables likesuper_read_only; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | super_read_only | ON | +-----------------+-------+ mysql> createtable tb_c (c int); ERROR 1290 (HY000): The MySQL server is running with the --super-read-only option so it cannot execute this statement # 关闭 read_only 参数 mysql> setglobal read_only = 0; Query OK, 0 rows affected (0.00 sec) 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.b2b供应网
                分享到:
                
温馨提示:以上内容和图片整理于网络,仅供参考,希望对您有帮助!如有侵权行为请联系删除!
猜你喜欢
- 揭秘巨人江湖游戏工会卡的魅力与功能(了解工会卡的一般情况以及如何获取和使用)
 - AKGK514MKII(带给你真实而清晰的音乐体验)
 - 解除Win7内存卡写保护的方法(轻松解决内存卡无法写入数据的问题)
 - 电脑安装系统教程(简明易懂的电脑操作指南,助你成功安装系统)
 - 三星GalaxyS4Zoom(将相机与手机完美结合,打造出色的拍摄体验)
 - AKGK514MKII(带给你真实而清晰的音乐体验)
 - 重装Windows10系统教程(详细步骤带你重新安装Windows10,让电脑焕然一新)
 - Mac和Win10教程大全(从入门到精通,轻松掌握Mac和Win10操作技巧)
 - 清华同方N768教程(一键开启科技新时代,解锁清华同方N768的神秘功能)