CodeIgniter 应用程序中的连接数超过 max_user_connections?

发布于 2024-12-09 10:08:15 字数 1080 浏览 0 评论 0原文

我在 CodeIgniter 应用程序中遇到了看起来相当严重的数据库错误。在日志文件中它说:

用户 anders 已经拥有超过 'max_user_connections' 活动连接

而且有几百行......我通过谷歌搜索读过一些内容,有些人认为这是因为你没有关闭使用后的连接,但其他人说这是无稽之谈,连接自动关闭(这也是我在文档中读到的)。

另外,稍后在日志文件中,我有以下错误消息:

ERROR - 2011-10-12 10:50:19 -->严重性:警告 --> file_get_contents(http://localhost/expertinfo/error/error_general) [function.file-get-contents]: 无法打开流: HTTP 请求失败! /Applications/MAMP/htdocs/expertinfo/application/errors/error_general.php 4

来使用自定义错误页面有关

echo file_get_contents($config['base_url'] . 'error/error_db');

这似乎与我通过重定向到自定义页面

。最后,我还得到:

ERROR - 2011-10-12 10:52:19 -->严重性:警告 --> mysql_pconnect() [function.mysql-pconnect]:无法连接到“mydb24.surftown.se”上的 MySQL 服务器 (4) /Applications/MAMP/htdocs/expertinfo/system/database/drivers/mysql/mysql_driver.php 88

在最后两个中,我不明白本地路径在那里做什么(我的计算机上的 CodeIgniter 应用程序的路径)。我的意思是这是系统文件夹的一部分,应该使用远程服务器上的文件夹,对吧?我已将数据库设置为远程数据库,但据我所知,没有任何本地路径......

那么为什么会发生这种情况,我该怎么办?

请帮忙,这看起来很紧急。我对 php 和 CodeIgniter 来说都是个新手,所以一个清晰简单的答案将不胜感激!

I'm getting what looks like rather serious database errors in my CodeIgniter application. In the log file it says:

User anders already has more than 'max_user_connections' active connections

And there are several hundred of those lines... I've read a bit by Googling, and some suggested that it was because you didn't close the connection after it was used, but others said that this was nonsense, and that the connection was automatically closed (which is what I read in the docs too).

Also, later in the log file, I have these error messages:

ERROR - 2011-10-12 10:50:19 --> Severity: Warning --> file_get_contents(http://localhost/expertinfo/error/error_general) [function.file-get-contents]: failed to open stream: HTTP request failed! /Applications/MAMP/htdocs/expertinfo/application/errors/error_general.php 4

This seems to have something to do with the fact that I'm using a custom error page by using

echo file_get_contents($config['base_url'] . 'error/error_db');

to redirect to a custom page.

Finally, I'm also getting:

ERROR - 2011-10-12 10:52:19 --> Severity: Warning --> mysql_pconnect() [function.mysql-pconnect]: Can't connect to MySQL server on 'mydb24.surftown.se' (4) /Applications/MAMP/htdocs/expertinfo/system/database/drivers/mysql/mysql_driver.php 88

In these last two, I don't understand what the local path is doing there (The path to my CodeIgniter app on my computer). I mean this is a part of the system folder and the one on the remote server should be used, right? I have the database set up as the remote database, and I don't have any local paths as far as I know....

So why does this happen, and what can I do about it?

Please help, this seems rather urgent. I'm a bit of a newbie to both php and CodeIgniter too, so a clear and simple answer would be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

花开半夏魅人心 2024-12-16 10:08:15

我看到的本地路径显示了发生错误的文件,因为您的驱动程序 /Applications/MAMP/htdocs/expertinfo/system/database/drivers/mysql/mysql_driver.php 可能在其 88 行包含 connect () 函数并引发异常问题

出在您的 mydb24.surftown.se 远程服务器上,您应该检查您的访问凭据等以找出到底发生了什么

Local path as I see shows you file where your error happened, because your driver /Applications/MAMP/htdocs/expertinfo/system/database/drivers/mysql/mysql_driver.php possible on it's 88 line contain connect() function and it raise an exception

The problem is with your mydb24.surftown.se remote server, you should check your access credentials, etc. to find what exactly happened

原野 2024-12-16 10:08:15

仅供参考,mysql_pconnect 在共享托管上通常是一个不好的做法(您可以在这里查看原因:http://stackoverflow.com/questions/1830830/advantages-disadvantages-of-pconnect-option-in-codeigniter)
您可能只是在 application/config/database.php 上禁用 pconnect 并看到错误消失,因为您的连接将真正降低。

Just an FYI, mysql_pconnect is usually a bad practice on shared hosting (you can see why here:http://stackoverflow.com/questions/1830830/advantages-disadvantages-of-pconnect-option-in-codeigniter)
You might just disable pconnect on application/config/database.php and see the error going away as your connections will be realluy lower.

战皆罪 2024-12-16 10:08:15

对于引用:“mysql_pconnect 在共享主机上通常是一个不好的做法”。
我改用mysql_connect。这没有什么区别。

For the quote: "mysql_pconnect is usually a bad practice on shared hosting".
I changed to use mysql_connect. It made no difference.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文