Solved

Limit number of MySql connections from a single IP Address

Posted on 2009-03-31
3
376 Views
Last Modified: 2012-08-13
Is there a way to configure MySql Server to put a limit on how many connections can be made from a single ip address?

We have a situation where an application is failing and making continuous connections to the MySql.  Eventually takes up all available connections.  While the real answer is to fix the application, an alternative would be to simply set a cap on how many connections can come from any single ip address.
0
Comment
Question by:markschenkel
  • 2
3 Comments
 
LVL 15

Expert Comment

by:oobayly
ID: 24032774
Does the application use a username not used by other clients? I'm guessing you've already thought about limiting connections on a user basis and discounted the idea.
Another option could be to schedule a script get all the connections, and kill any for the IP that are over a certain age.
Personly I reckon that this is beyond MySql's capability (and remit). ipfw or iptables would probably the route to take, especially given Linux's penchant for each tool having a specific task.
0
 
LVL 21

Accepted Solution

by:
theGhost_k8 earned 125 total points
ID: 24037854
It can be done by grant command as follows:
GRANT ALL ON customer.* TO 'USERNAME'@'IP ADDRESS'
      WITH MAX_QUERIES_PER_HOUR 20
      MAX_UPDATES_PER_HOUR 10
      MAX_CONNECTIONS_PER_HOUR 5
      MAX_USER_CONNECTIONS 2;
0
 
LVL 15

Expert Comment

by:oobayly
ID: 24037883
<Slaps forehead with palm>: Why didn't I think of that.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now