Php Laravel 5.1:PDO异常:已超过';最大用户连接数';资源

Php Laravel 5.1:PDO异常:已超过';最大用户连接数';资源,php,mysql,laravel,testing,laravel-5.1,Php,Mysql,Laravel,Testing,Laravel 5.1,我在Laravel 5.1中对一台临时服务器上的MySQL数据库运行功能测试,并得到以下错误: PDOException:SQLSTATE[HY000][1226]用户“username”已超过“max_User_connections”资源(当前值:20) TestCase类看起来像: <?php use Illuminate\Support\Facades\Artisan; use Illuminate\Foundation\Testing\DatabaseTransactions;

我在Laravel 5.1中对一台临时服务器上的MySQL数据库运行功能测试,并得到以下错误:

PDOException:SQLSTATE[HY000][1226]用户“username”已超过“max_User_connections”资源(当前值:20)

TestCase类看起来像:

<?php

use Illuminate\Support\Facades\Artisan;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class TestCase extends Illuminate\Foundation\Testing\TestCase
{

    /**
     * Rollback and execute migrations for each test.
     */
    use DatabaseTransactions;

    /**
     * The base URL to use while testing the application.
     *
     * @var string
     */
    protected $baseUrl = 'http://localhost';

    /**
     * Is this the first test.
     *
     * @var bool
     */
    protected static $isInitialTest = true;

    /**
     * Creates the application.
     *
     * @return \Illuminate\Foundation\Application
     */
    public function createApplication()
    {
        $app = require __DIR__.'/../bootstrap/app.php';

        $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();

        return $app;
    }

    /**
     * If this is the first test of the actual test suite:
     * Delete all test table records and run migrations.
     *
     * @return void
     */
    public function setUp()
    {
        parent::setUp();

        if(self::$isInitialTest){

            self::$isInitialTest = false;

            Artisan::call('migrate');
        }
    }

}
我正在进行这样的测试
vendor/phpunit/phpunit/phpunit--bootstrap./bootstrap/autoload.php./tests/

除了提高
max\u user\u connections
我还能做些什么来控制并行数据库连接的打开量?如果可能,我不想减慢测试速度:)


在我的本地开发机器上,
max\u user\u connections
设置为
0
,因此没有限制,也没有错误。

如何打开所有用户连接?你能告诉我们一个测试,也许你是如何运行它的吗?我不确定我是如何打开所有的用户连接的,我猜Laravel框架会为每个测试打开一个连接(目前有45个测试),并且不会重用可用的连接。这有意义吗?我添加了一个示例测试和用于运行测试的命令。
use Illuminate\Foundation\Testing\WithoutMiddleware;

class AreasTest extends TestCase
{
    /**
     * Add a new area to a tenant.
     */
    public function testAddArea()
    {
        $tenant = factory('XXX\Tenant', 'xxx')->create();

        $this->visit("admin/tenants/{$tenant->id}")
            ->click('…')
            ->click('N…')
            ->type('…', 'name')
            ->press('…')
            ->see('…');
    }
…
}