How to connect to remote mySQL database in Yii2

I am using Yii 2.0 basic template. I tried to connect to the DB. The connection in the local db works. But I cannot connect to the remote mySQL-db which is on the domain server.

This is my db config:

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=smargav.com;dbname=smargavc_Konnections',
    'username' => 'smargavc_Konnect',
    'password' => '******',
    'charset' => 'utf8'
];

      

I am getting the error:

{"name": "Database exception", "message": "SQLSTATE [HY000] [1045] Access for user 'smargavc_Konnect'@'122.167.47.26' (using password:

+3


source to share


1 answer


the connection string seems fine

Several possible reasons:



  • User smargavc_Konnect does not have permission to connect remotely
  • MYSQL is in a stopped state on the remote server
  • Port 3306 is not allowed on the remote server.
  • Your IP address is not allowed to access the remote server using http

Check if they are all correct, you can connect to

+1


source







All Articles