Solved

Limit number of MySql connections from a single IP Address

Posted on 2009-03-31
3
382 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
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…

820 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