laravel 已经有超过 'max_user_connections' 个活动连接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40545817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 14:43:42  来源:igfitidea点击:

already has more than 'max_user_connections' active connections

phpmysqllaravel

提问by Pradyut Manna

I am implementing a website by laravel.There is a problem that some times it shows some error already has more than 'max_user_connections' active connectionshow to solve this?enter image description here

我正在通过 laravel 实现一个网站。有一个问题,有时它会显示一些错误already has more than 'max_user_connections' active connections如何解决这个问题?在此处输入图片说明

回答by Kalmár Gábor

You can pass PDO options to the connection (it is not well documented, but the code won't lie: https://github.com/laravel/framework/blob/5.2/src/Illuminate/Database/Connectors/Connector.php#L33) in app/config/database.phplike this:

您可以将 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
            ]
        ],

        ...