原创MySQL常用脚本整理
Posted 数据库技术
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了原创MySQL常用脚本整理相关的知识,希望对你有一定的参考价值。
#1、查看表容量空间
SELECT TABLE_SCHEMA,TABLE_NAME,TABLE_ROWS,ROUND(DATA_LENGTH/1024/1024/1024) AS \'data_size(G)\',ROUND(INDEX_LENGTH/1024/1024/1024) AS \'index_size(G)\',ROUND(DATA_FREE/1024/1024/1024) AS \'free_size(G)\' FROM information_schema.tables WHERE TABLE_SCHEMA=\'test\' AND TABLE_NAME IN (\'sbtest1\');
#2、查看用户连接
select user,count(1) as num from information_schema.processlist group by user;
#3、批量kill用户连接
select concat(\'kill \',id,\';\') from information_schema.processlist where user like \'%user%\' into outfile \'/tmp/killpid.sql\'; source /tmp/killpid.sql
以上是关于原创MySQL常用脚本整理的主要内容,如果未能解决你的问题,请参考以下文章