PDOException:一般错误:2006 MySQL 服务器已消失

May*_*rma 1 mysql drupal exception

德鲁帕尔7

每当我访问配置 > 搜索和元数据 > URL 别名 > 模式 (localhost/admin/config/search/path/patterns) 时,我都会收到此错误

原来的

PDOException: SQLSTATE[HY000]: 一般错误: 2006 MySQL 服务器已经消失: SELECT 1 AS 表达式 FROM {variable} 变量 WHERE ( (name = :db_condition_placeholder_0) ); Variable_set() 中的数组( [:db_condition_placeholder_0] => drupal_css_cache_files )(/home/www/icts-website/includes/bootstrap.inc 的第 991 行)。

额外的

PDOException:SQLSTATE [HY000]:一般错误:2006 MySQL服务器已经消失:INSERT INTO {watchdog}(uid,类型,消息,变量,严重性,链接,位置,引用者,主机名,时间戳)VALUES(:db_insert_placeholder_0,:db_insert_placeholder_1 、:db_insert_placeholder_2、:db_insert_placeholder_3、:db_insert_placeholder_4、:db_insert_placeholder_5、:db_insert_placeholder_6、:db_insert_placeholder_7、:db_insert_placeholder_8、:db_insert_placeholder_9);数组 ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => php [:db_insert_placeholder_2] => %type: !message in %function (第 %line of %file)。[:db_insert_placeholder_3] => a:6:{ s:5:"%type";s:12:"PDOException";s:8:"!message";s:235:"SQLSTATE[HY000]: 一般错误: 2006 MySQL 服务器已经消失: SELECT 1 AS 表达式FROM {variable} 变量 WHERE ( (name = :db_condition_placeholder_0) ); Array ( [:db_condition_placeholder_0] => drupal_css_cache_files ) ";s:9:"%function";s:14:"variable_set()";s:5: "%file";s:45:"/home/www/icts-website/includes/bootstrap.inc";s:5:"%line";i:991;s:14:"severity_level";i:3 ;} [:db_insert_placeholder_4] => 3 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://localhost/admin/config/search/path/patterns [:db_insert_placeholder_7] => http://localhost/ [: db_insert_placeholder_8] => 10.0.8.14 [:db_insert_placeholder_9] => 1444714070 ) 在 dblog_watchdog() 中(/home/www/icts-website/modules/dblog/dblog.module 的第 160 行)。

关闭函数中抛出未捕获的异常。

PDOException: SQLSTATE[HY000]: 一般错误: 2006 MySQL 服务器已经消失: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; lock_release_all() 中的数组( [:db_condition_placeholder_0] => 399784779561c9655b48719.42544548 )(/home/www/icts-website/includes/lock.inc 的第 269 行)。

我用谷歌搜索了解决方案,并将 max_allowed_pa​​cket 增加到 32M,但错误页面仍然存在。

我将非常感谢您帮助解决这个问题。

my.cnf文件详细信息如下:

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

# include all files from the config directory
!includedir /etc/my.cnf.d

max_allowed_packet = 32M
Run Code Online (Sandbox Code Playgroud)

我使用的是 CentOS 7 和 MySQL。

ken*_*orb 5

是的,此错误与解析大量数据有关,因此数据库会失败,因为由于给定的限制,它无法处理此类大小,因此服务器超时并关闭连接。

要解决此问题,您需要进一步增加(例如)部分中max_allowed_packet的值,例如my.cnf~/.my.cnf[mysqld]

[mysqld]
max_allowed_packet=256M
Run Code Online (Sandbox Code Playgroud)

尝试使用256M,如果没有帮助,请尝试进一步增加(例如1G)。

就您而言,我认为max_allowed_packet应该专门在[mysqld]部分下,而不是在 下[mysqld_safe],因此设置将应用于正确的组件。

请参阅:B.5.2.9 MySQL 服务器已消失以获取更多详细信息。

另一件事是,在这种特殊情况下,它发生在关闭功能中(在 Drupal 完成站点处理之后),因此它可能与某些 cron 或调试任务有关。