简体   繁体   中英

MySQL: "Too many connections"?

I'm getting this error:

Warning: mysql_connect() [function.mysql-connect]: Too many connections in /home1/host/public_html/employee/message/config.php on line 4

Could no connect to database. Too many connections

No one else is on my site at the moment. I'm the only one.

I do have a lot of AJAX, but the connections close after they're done. That is why I don't understand why I have a too many connections error.

您可以尝试通过查询您的 MYSQL 来查看在您执行 AJAX 请求后连接是否正确关闭吗?

Are you using a webserver (IIS, Apache, etc)? They often pool the connections and hang on to them for a while to keep queries running fast. If you are, try restarting your webserver app (in IIS, Start -> Run "iisreset") and see if that frees it up.

This issue is due to Multiple connection instance are active at a time. Use Singleton object for Connection object creation.

Make sure you close all existing database connections before making another connection. Do this by using the code $mysqlConnectionName->close();or mysql_close($mysqlConnectionName);

I had the same issue in a custom framework that I am using. The solution was to create one connection per http request (new mysqli).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM