-- 查询哪些查询时间大于20秒 select*from information_schema.processlist where COMMAND='Query'ANDtime>20; -- 批量kill慢查询 select concat('KILL ',id,';') from information_schema.processlist where COMMAND='Query'ANDtime>20;
复制输出的结果, 再执行
查看版本
查看变量的方式
1
show variables like'%version%';
mysql命令行执行命令的方式
1
status
使用MySQL函数方式:
1
select version();
查看哪些库使用的是MyISAM引擎
查询哪些表引擎是MyISAM
1
SELECT TABLE_SCHEMA as DbName ,TABLE_NAME as TableName ,ENGINE as Engine FROM information_schema.TABLES WHERE ENGINE='MyISAM'AND TABLE_SCHEMA NOTIN('mysql','information_schema','performance_schema');
生成 ALTER 语句来转换到 InnoDB
1
SELECT CONCAT('ALTER TABLE ', TABLE_SCHEMA,'.',TABLE_NAME, ' ENGINE = InnoDB;') FROM information_schema.TABLES WHERE ENGINE='MyISAM'AND TABLE_SCHEMA NOTIN('mysql','information_schema','performance_schema');