SQLSTATE [HY000] [1040]连接太多 [英] SQLSTATE[HY000] [1040] Too many connections

查看:1964
本文介绍了SQLSTATE [HY000] [1040]连接太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我打开错误日志文件时会看到此错误

Sometimes when I open my error log file I see this this error

[2014年6月14日19:09:55 UTC] PHP致命错误:未捕获的异常 消息"SQLSTATE [HY000]"的"PDOException" [1040]太多 连接"位于/home/root/products/db.php:2

[14-Jun-2014 19:09:55 UTC] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1040] Too many connections' in /home/root/products/db.php:2

堆栈跟踪:/home/root/products/db.php(2): PDO-> __ construct('mysql:host = loca ...','database','password')

Stack trace: /home/root/products/db.php(2): PDO->__construct('mysql:host=loca...', 'database', 'password')

/home/root/products/by-brand.php(2):include_once('/home/root/...')

/home/root/products/by-brand.php(2): include_once('/home/root/...')

{main}在第2行的/home/root/products/db.php中抛出

{main} thrown in /home/root/products/db.php on line 2

[2014年6月14日19:15:11 UTC] PHP致命错误:消息为'SQLSTATE [42000]的未捕获异常'PDOException':语法错误或访问 违反:1286中的未知存储引擎InnoDB /home/root/products/detail.php:8

[14-Jun-2014 19:15:11 UTC] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1286 Unknown storage engine InnoDB in /home/root/products/detail.php:8

堆栈跟踪:/home/root/products/name.php(8):PDO-> prepare('select * 从p ...')

Stack trace: /home/root/products/name.php(8): PDO->prepare('select * from p...')

{main}在第8行的/home/root/products/name.php中抛出

{main} thrown in /home/root/products/name.php on line 8

我正在尝试通过使用$db=null;关闭每个脚本来解决此问题,但是它似乎不起作用.

I am trying to solve this issue by closing every script by using $db=null; but it doesn't seem to work.

我联系了服务提供商.他们说一切正常.您需要在最后检查错误.我只有几个用户.

I contacted the service provider. They say everything works fine. You need to check errors at the end. I have just a few users.

为什么有时会出现此错误?

Why do I somestimes get this error?

我的托管不受限制:磁盘空间不受限制.无限带宽,但仍然出现此错误.我不知道该如何解决这个问题.我希望扩大我的网站,但这些错误使我感到困惑

My hosting is unlimited: unlimited disk space. unlimited bandwidth but still I get this error. I don't know how can I solve this issue. I hope to make my website larger but these error make me confuses

我的db.php文件具有此代码.你可以检查一下吗?也许这是造成问题的原因.

My db.php file has this code. Can you check if this fine? Maybe this is causing the problem.

db.php

$db = new PDO('mysql:host=localhost;dbname=mobiles;charset=utf8', 'root', '**somePassword**');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

推荐答案

您的连接代码没有错.

共享主机上,无限制"表示其他用户不受资源使用限制.意味着他们可以吃饱整个游泳池,而您的消费却保持适度.

On a shared hosting, "unlimited" means other users are unrestricted with their resource using. Means they can eat up whole pool, while your consumption remains modest.

您已经在评论中被告知,请不要使用该主机.

As you've been told in comments, don't use this host.

这篇关于SQLSTATE [HY000] [1040]连接太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆