MySQL设置数据库为只读

IT科技2025-11-05 03:42:233154
MySQL设置数据库为只读
复制# 查看 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,IT技术网再次使用超级权限用户来操作数据  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供应网
本文地址:http://www.bzuk.cn/html/280c8899631.html
版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

全站热门

声卡驱动的使用教程(轻松了解声卡驱动的安装和设置方法)

2024 年十大优秀漏洞管理工具

MySQL临时表在高并发环境下可能导致哪些性能问题?

准线上事故之MySQL优化器索引选错

乐视1s手机评价如何?(从用户角度看乐视1s手机的优点和问题)

五种主流数据库:常用数值函数

Linux下如何使用minicom USB串口

只针对Linux,甲骨文Weblogic服务器被黑客入侵

友情链接

滇ICP备2023006006号-33