时间: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_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;';
mysql -h localhost -P 3306 -u root -pmysql -D test -s < d:\atmp\backup_perf_setup.sql > d:\ATMP\restore_perf_setup.sql
update performance_schema.setup_instruments set enabled='YES' where enabled='NO'; update performance_schema.setup_consumers set enabled='YES' where enabled='NO'; commit;
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
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');