Laravel5设置数据库端口?

我的数据库端口8889

DB_HOST=127.0.0.1
DB_PORT=8889

terminal报错:
[PDOException]

SQLSTATE[HY000] [2002] Connection refused

网页报错
PDOException in Connector.php line 47: SQLSTATE[HY000] [2002] Connection refused

in Connector.php line 47
at PDO->__construct('mysql:host=127.0.0.1;dbname=insist', 'root', 'root', array('0', '2', '0', false, '0')) in Connector.php line 47
at Connector->createConnection('mysql:host=127.0.0.1;dbname=insist', array('driver' => 'mysql', 'host' => '127.0.0.1', 'database' => 'insist', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, '0')) in MySqlConnector.php line 20
at MySqlConnector->connect(array('driver' => 'mysql', 'host' => '127.0.0.1', 'database' => 'insist', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in compiled.php line 10791
at ConnectionFactory->createSingleConnection(array('driver' => 'mysql', 'host' => '127.0.0.1', 'database' => 'insist', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in compiled.php line 10787
at ConnectionFactory->make(array('driver' => 'mysql', 'host' => '127.0.0.1', 'database' => 'insist', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false), 'mysql') in compiled.php line 10705
at DatabaseManager->makeConnection('mysql') in compiled.php line 10660
已邀请:

popo7to

赞同来自:

config/database.php中增加:
'port' => env('DB_PORT', 'localhost'),

丫hoo

赞同来自:

DB_HOST=localhost:3307
DB_DATABASE=homestead
DB_USERNAME=root
DB_PASSWORD=147258

丫hoo

赞同来自:

'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,
        'port'      => 3307,
    ],

要回复问题请先登录注册