donpvtzuux37724 2015-01-30 03:11
浏览 603
已采纳

SQLSTATE [HY000] [2002]连接被拒绝 - 引起:PDOException

I have the following settings in config/db.php:

return [
    'class' => 'yii\db\Connection'
    'dsn' => 'mysql:host=myURL;dbname=mydb', 
    'username' => 'mydbUsername',
    'password' => 'mydbPassword',
    'charset' => 'utf8',
];

That above string works in my test-machine, however in the server where I deployed the app does not work.

What is wrong? Thanks.

  • 写回答

2条回答 默认 最新

  • doulu1325 2015-01-30 04:19
    关注

    host=myURL ?? try host=localhost

    Unless you are using a different machine for the mysql server, but I guess you are not.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?