kill ALL mysql processes

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

kill ALL mysql processes

Post by GeXus »

Anyone know how to do this? or at least how to kill all sleep connections

Thanks!
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

They will normally timeout on their own. BTW, if you are using persistent connections you might want to change to normal connections. What with the changes in how Mysql works persistent connections are not faster and do not save any processing time but they do eat up memory and can cause mysql to run out of available connections. This will cause the some people to see the too many connection error when they try to access the site.

If you are using persistent connections you really should stop. Honestly the only reason I think they still keep it is for backwards compatibility.
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

i use mysql_connect and close all connections at the end of the script.. is that what you mean?

These current processes have been running for a while now, there are about 300, most of which are in sleep.. it seems that i can only have 3 threads going at a time... can I increase that?
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Also, just to add if i can kill all processes by user, that would work just fine as well.
User avatar
veridicus
Forum Commoner
Posts: 86
Joined: Fri Feb 23, 2007 9:16 am

Post by veridicus »

Be careful killing mysql processes. Killing all with -9 has the potential to corrupt your database files.
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Just wanted to come back to this, i have tons of sleeping processes still and no where can I find out how to kill them all.. or disable them.. I'm not entirely sure what this even means, i just know that my server seems to be running quite slow and i have all these processes running.

Is there an ideal way to setup everything if it will be highly transactional to prevent this from happening in the future?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Restart the MySQL server?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Can't restart without killing all processes :p
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Okay, I was able to kill all processes using

Code: Select all

ps ax | grep mysqld

then

kill -9 PID#

Now the question is how to prevent sleeping threads from occurring in the future!
Post Reply