Deen
Deen

Reputation: 621

How to connect to remote mySQL DB in Yii2

I'm using Yii 2.0 basic template. I have tried to connect to the DB. The connection in local db is working. But I'm not able to connect to the remote mySQL db that is in 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'm getting error as following:

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

Upvotes: 3

Views: 4239

Answers (1)

vishal vasudeva
vishal vasudeva

Reputation: 85

connection string seems fine

Several possible causes :

  1. smargavc_Konnect user doesn't have permission to connect remotely
  2. MYSQL is in stopped state at remote server
  3. 3306 port is not allowed in remote server
  4. Your IP is not allowed to access the remote server using http

Check if all of these are true , you should be able to connect

Upvotes: 1

Related Questions