I\'m currently getting this error in the front-end only (not inside /wp-admin):
Warning: mysqli_real_connect(): (HY000/1203): User xxx already has more than
\'max_user_connections\' active connections in
/hermes/.../public_html/myhome/wp-includes/wp-db.php on line 1489
Warning: mysql_connect(): User xxx already has more than
\'max_user_connections\' active connections in
/hermes/.../public_html/myhome/wp-includes/wp-db.php on line 1515
Error establishing a database connection
我想知道,当我是唯一的访客时,为什么会出现这种情况?我正在使用WP 4.5。
I did contact the host who was kind enough to reply as below:
Currently your website is showing
\'Error establishing a database
connection\' because the user of the
database has exceeded the
concurrent connection limit for a
user of a database, which is 10. This
is the reason website is loads
database error. The script throws the
concurrent connection error when
number of database connections
exceed the limit set on the server. In
our shared platform, we allow
maximum of 10 concurrent
connections to a database, which is
ideal in the shared platform and it is
not possible to increase this limit.
The query limit for your website will
be reset within couple of hours so
you should be able to access the
database after couple of hours.
There are two cases the script loads
above error, one is when there is a
high traffic to the website and
database concurrent connection hits
the limit and second case is the
database connection is not closed in
the script, even for the moderate
traffic the script loads concurrent
connection error. To overcome this
issue, you have to close the database
connection immediately after
fetching the required content from
the database. To close the database
connection you can use
mysql_close() PHP function with
connection parameter. This will help
you to use database connection limit
efficiently.
换言之,在我们这边一切都很好,这是一个WP错误。
SO网友:kaiser
首先要为启用错误$wpdb
, WP数据库抽象:
$GLOBALS[\'wpdb\']->show_errors;
否则,您的DB连接都不会因
\\WP_Error
. 默认错误代码为
500
.
以下错误来自\\wpdb::db_connect()
:
建立数据库连接时出错
有两种情况db_connect()
开始使用:
连接到数据库,检查是否连接到数据库,只有第一个数据库才允许跳转。如果仅执行检查时连接会断开,则会not 死了,不要抛出这个错误。现在连接由\\wpdb_driver::connect()
, 它提供了连接是否已启用和可用的检查。这告诉您,您的实际问题实际上是连接本身。你可以查一下(no joke) 在以下文件中:
# interface-wp-db-driver.php
<?php
abstract class wpdb_driver {
您最好不要考虑WP核心代码的总体质量与这里对接口和抽象类的深入理解是否有任何关联
就在DB连接将被声明为“失败”并且错误将被转储之前,有一句很好的话:
require_once WP_CONTENT_DIR . \'/db-error.php\';
这意味着
Drop In 在一切之前加载
die
s、 您可以使用它并在那里启动调试机制。您有完整的可湿性粉剂核心可用在那里。你可以开始给自己发电子邮件,把这些错误记录在一些ELK/Kibana、Spark或任何堆栈、一些SaaS甚至Slack(或只是一个文本文件)中。在那里记录您的错误,记录发生的情况,转储路由、请求、数据库连接详细信息,以及您认为可能对您有帮助的任何内容。