已经超过'max_user_connections'活动连接

时间:2016-11-11 10:18:31

标签: php mysql laravel

我正在通过laravel实现一个网站。有一个问题,有时它会显示一些错误already has more than 'max_user_connections' active connections如何解决这个问题?enter image description here

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

您可以将PDO选项传递给连接(没有详细记录,但代码不会谎言:https://github.com/laravel/framework/blob/5.2/src/Illuminate/Database/Connectors/Connector.php#L33)在 app / config / database.php 中,如下所示:

...

'connections' => [
        ...

        'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'forge'),
            'username'  => env('DB_USERNAME', 'forge'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
            'engine'    => null,
            'dump_command_path' => '/opt/mysql/bin', 
            'options' => [
                PDO::ATTR_PERSISTENT => false //@todo
            ]
        ],

        ...