0
votes

Now i'm using multiple database connection using Lumen. I am confused how to write the correct db host via an external url in the configuration of the laravel or lumen mysql database connection

example url : hidden.link.com:3306

i've tried this in my env file DB_HOST_SECOND=mysql://hidden.link.com:3306

and define on config/database.php like this

'connections' => [
    'mysql' => [
        'driver'    => 'mysql',
        'host'      => env('DB_HOST'),
        'database'  => env('DB_DATABASE'),
        'username'  => env('DB_USERNAME'),
        'password'  => env('DB_PASSWORD'),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => false,
        'engine' => null,
    ],
    'mysql2' => [
        'driver'    => 'mysql',
        'host'      => env('DB_HOST_SECOND', 'mysql://hidden.link.com:3306'),
        'database'  => env('DB_DATABASE_SECOND'),
        'port'      => env('DB_PORT_SECOND', 3306),
        'username'  => env('DB_USERNAME_SECOND', 'username'),
        'password'  => env('DB_PASSWORD_SECOND', 'password'),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => false,
        'engine' => null,
    ],
],
1

1 Answers

1
votes

Don't use mysql: prefix and port in host param. Just type your domain DB_HOST_SECOND=hidden.link.com