c++ - MYSQL Too many connections error will not go away -


I am getting a MySQL "Too many connections" error in the C ++ program running on Ubuntu Linux.

This is the code that is the error (this is a method that returns mysql error, if any):

  MySQL Connect; Mysql_init (& amp; connect); If (mysql_real_connect (and connect, server, user, password, database, 0, zero, 0)) {mysql_error (and connect); }  

This code is returning the "too many connections" string.

I am surprised that this is actually some other error before I get this error, this program is working for a few months when the error was first appearing, so I have several thousand updates / Read and run the program against so many, it is very possible that I used the available connection. The problem is, I can not find any way to release them, if it is the same.

Here's what I have tried:

  • Flush Hops;
  • Restarting MYSQL
  • Rebooting the Machine Completely

This error is more than 12 hours Has been seen first, so if it is a connection then nothing is being reset / released, I would have thought that the rebooting machine would have released some.

see

See all MySQL connections.

  netstat -apn | Grep mysql | Setting up Grep -i  

Tips

  • Connection pointer is empty or if the connection is not available for DB, return the connection object and return it.
  • Use a connection pool for the entire session.
  • Close the connection at the end of each session and release / clear the connection indicator.
  • Increase max_connections = # in /etc/mysql/my.cnf or MySQL to - max_connections = #
Restart with

Comments