当前位置:Gxlcms > mysql > MySQL5.6中备份及复原performance_schema配置

MySQL5.6中备份及复原performance_schema配置

时间:2021-07-01 10:21:17 帮助过:129人阅读

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\backup_perf_setup.sql > 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 < d:\ATMP\restore_perf_setup.sql


五、清空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');

人气教程排行