如何终止MySQL连接 [英] How to kill MySQL connections

查看:90
本文介绍了如何终止MySQL连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用MySQL建立一个网站.我正在将TOAD用于MySQL,突然出现错误,便无法连接到数据库:

I'm building a website with MySQL. I'm using TOAD for MySQL and suddenly I can't connect to the database as I'm getting an error:

连接过多"

Toad for MySQL中是否可以查看现有连接以杀死它们或简单地将所有连接全部关闭?

Is there any way in Toad for MySQL to view existing connections to be able to kill them or simple close all connections all together?

推荐答案

否,没有没有内置的MySQL命令.有多种支持它的工具和脚本,您可以手动终止某些连接或重新启动服务器(但这会比较慢).

No, there is no built-in MySQL command for that. There are various tools and scripts that support it, you can kill some connections manually or restart the server (but that will be slower).

使用SHOW PROCESSLIST查看所有连接,并使用KILL您要终止的进程ID.

Use SHOW PROCESSLIST to view all connections, and KILL the process ID's you want to kill.

您可以编辑超时设置,以使MySQL守护程序自行杀死不活动的进程,或增加连接数.您甚至可以限制每个用户名的连接数量,这样,如果该进程持续出现异常,则唯一受影响的进程是该进程本身,而数据库上的其他客户端也不会被锁定.

You could edit the timeout setting to have the MySQL daemon kill the inactive processes itself, or raise the connection count. You can even limit the amount of connections per username, so that if the process keeps misbehaving, the only affected process is the process itself and no other clients on your database get locked out.

如果您无法再将自己连接到服务器,则应该知道MySQL始终为具有 SUPER特权的用户保留1个额外的连接.除非您的违规程序由于某种原因而使用具有该特权的用户名...

If you can't connect yourself anymore to the server, you should know that MySQL always reserves 1 extra connection for a user with the SUPER privilege. Unless your offending process is for some reason using a username with that privilege...

然后,在可以再次访问数据库之后,应该修复产生大量连接的过程(网站).

Then after you can access your database again, you should fix the process (website) that's spawning that many connections.

这篇关于如何终止MySQL连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆