好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

mysql 清理command为sleep的连接进程

> SELECT concat( ‘ KILL ‘ , id , ‘ ; ‘ ) FROM information_schema.processlist WHERE user= ‘ user1 ‘ ; mysql > select concat( ‘ KILL ‘ , id , ‘ ; ‘ ) from information_schema.processlist where user= ‘ root ‘ into outfile ‘ /tmp/a.txt ‘ ; mysql > source /tmp/a.txt;

其中上面root用户是“show processlist;” 命令下,User列对应最多的Sleep进程连接状态的用户。

注 :如上面导出为指定文件路径报“ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement”错误。

 

 是由于MySQL在文件的导入、导出有个默认的文件路径。通过“show variables like ‘%secure%‘;”命令查看默认导入、导出文件路径。

 

从上面可看出默认路径为“/var/lib/mysql-files/”;所以改下导出文件路径:

mysql> SELECT concat( ‘  KILL   ‘ , id , ‘  ;  ‘ ) FROM information_schema.processlist WHERE user= ‘  root  ‘  into outfile  ‘  /var/lib/mysql-files/a.txt  ‘ ;

然后在执行“source /var/lib/mysql-files/a.txt;”命令,接下来是出现一堆“Query OK, 0 rows affected (0.00 sec)”,执行成功。

 

mysql 清理command为sleep的连接进程

标签:int   导入   lazy   roc   rom   mamicode   --   cut   where   

查看更多关于mysql 清理command为sleep的连接进程的详细内容...

  阅读:27次

上一篇: Mysql-安装

下一篇:mysql视图的简单学习