SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

0

已经在 config/bootstrap.php 中加了 support\bootstrap\db\Heartbeat::class


<?php
/**
* This file is part of webman.
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor<walkor@workerman.net>
* @copyright walkor<walkor@workerman.net>
* @link http://www.workerman.net/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

return [
support\bootstrap\Container::class,
support\bootstrap\Session::class,
support\bootstrap\db\Laravel::class,
support\bootstrap\Redis::class,
support\bootstrap\Log::class,
support\bootstrap\Translation::class,
support\bootstrap\db\Heartbeat::class
];
已邀请:

wjm989

赞同来自:

晕, 是不是最后一行少个逗号?最后一行一定要有逗号吗?看着是返回数组,没逗号也行吗?

wjm989

赞同来自:

default.ERROR: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away {"exception":"PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in

wjm989

赞同来自:

bootstrap.php 和 start.php 中都加了 DB::query('select 1'); 还是报这个错,这怎么办?

six

赞同来自:

看源码心跳默认是主连接定时发了心跳。如果你用了多个数据库连接,需要改下support\bootstrap\db\Heartbeat类,让每个连接都发送心跳。

wjm989

赞同来自:

默认心跳类时间间隔太长了,要改成 10 秒才行

要回复问题请先登录注册