1
I have 8 open connections in the database and would like to close all of them, is possible?
What is the Mysql command that does this?
1
I have 8 open connections in the database and would like to close all of them, is possible?
What is the Mysql command that does this?
6
It does not exist directly but it is possible to do this. Run this in Mysql:
select concat('KILL ',id,';') from information_schema.processlist where user='root' into outfile '/tmp/a.txt';
afterward
source /tmp/a.txt;
You can do this too:
SELECT GROUP_CONCAT(CONCAT('KILL QUERY ',id,';') SEPARATOR ' ') KillQuery
FROM information_schema.processlist WHERE user<>'system user'\G
To rotate on the command line:
mysql -NBe "SELECT CONCAT('KILL ', id, ';') FROM information_schema.processlist WHERE user = 'some_username';" | mysql -vv
source is giving syntax error
In this link shows how to run without saving to file but yes using variables.
There are other options. See link of the source is doing the same.
are two separate commands @Lucassousa, run one and then run the other
Browser other questions tagged mysql sql database
You are not signed in. Login or sign up in order to post.
Does not work mysql_close() ?
– buback
put the code you open the connection with Mysql
– krispim
What exactly do you want to do?
– RFL
I wanted to do this by giving a command in the bank and not by code, I am using the workbanch
– Lucas Sousa
mysql_close()
as well asmysql_
is DEPRECATED, if using placemysqli_*
in place– Giancarlo Abel Giulian
Some systems make persistent connections or try to reconnect every time the system loses connection, stay tuned for this.
– rray
I can’t test, so I can’t write an answer with this, but it’s worth taking a look https://www.percona.com/blog/2009/05/21/mass-killing-of-mysql-connections/
– Luis Henrique
mysql_close() is not running
– Lucas Sousa
Where’s the tag saying the subject is about PHP? Provide more details about the language you are using, this is important for those reading the question and having to give an answer. Or is it even important to those who will have their doubt
– Wallace Maxters
It has nothing to do with PHP. OP just wants to disconnect everything world at once. a Restart solves :P hehe
– rray
that same rray, I just want to take down all connections, independent of system
– Lucas Sousa
@Lucassousa Take a look at [tour]. You can accept an answer if it solved your problem. You can vote for all the posts on the site as well. Did any help you more? You need something to be improved?
– Maniero