MySQL 5.6中备份及复原performance_schema配置
程序员文章站
2022-06-13 11:21:53
...
MySQL 5.6中备份及还原performance_schema配置 一、setup.txt文件,用于备份performance_schema的配置。该脚本生成还原performance_schema中的setup表的SQL语句。 -- 备份setup_instrumentsselect concat('update performance_schema.setup_instruments set e
MySQL 5.6中备份及还原performance_schema配置一、setup.txt文件,用于备份performance_schema的配置。该脚本生成还原performance_schema中的setup表的SQL语句。
-- 备份setup_instruments select concat('update performance_schema.setup_instruments set enabled=''',enabled,''' where name=''',name,''';') from performance_schema.setup_instruments where enabled='NO'; -- 备份setup_consumers select concat('update performance_schema.setup_consumers set enabled=''',enabled,''' where name=''',name,''';') from performance_schema.setup_consumers where enabled='NO'; -- commit select 'commit;';
二、执行setup.txt文件,备份performance_schema的配置。
mysql -h localhost -P 3306 -u root -pmysql -D test -s d:\ATMP\restore_perf_setup.sql
三、开启所有的setup配置进行监控。
update performance_schema.setup_instruments set enabled='YES' where enabled='NO'; update performance_schema.setup_consumers set enabled='YES' where enabled='NO'; commit;
四、监控完成后,还原performance_schema的配置。
D:\software\mysql\mysql-5.6.14-win32\bin>mysql -h localhost -P 3306 -u root -pmysql -D test -s
五、清空performance_schema的监控表的记录。SELECT CONCAT('truncate table performance_schema.',table_name,';') FROM information_schema.TABLES WHERE table_schema='performance_schema' AND table_name NOT LIKE 'setup%' AND table_name NOT LIKE '%instances' AND table_name NOT LIKE '%attrs' AND table_name NOT IN ('performance_timers', 'threads');
上一篇: api设计 - php 接口 token 数据加密
下一篇: 首字母缩进!!!!!