Solved

Limit number of MySql connections from a single IP Address

Posted on 2009-03-31
3
385 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Foreword This article was written many years ago, in the days when PHP supported the MySQL extension (http://php.net/manual/en/function.mysql-connect.php).  Today (http://php.net/manual/en/migration70.removed-exts-sapis.php) you would not use MySQL…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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