samedi 25 mars 2017

Laravel Forge how to establish connection between 2 databases on 2 separate servers

I have an app built on app.mydomain.com (Server 1) and a support ticketing system at support.mydomain.com (server 2). How can I establish a connection between both databases in my laravel app? Both are using Laravel Forge and Digital Ocean.

I read this post on SO which looked great but I am getting a "connection timed out error". I believe it has to do with Forge needing the SSH key file (id_rsa.pub) when connecting to a database? Source here

I tried adding this to database.php:

//Server/Site 1
'mysql' => array(
    'driver'    => 'mysql',
    'host'      => 'localhost',
    'database'  => 'support',
    'username'  => 'user',
    'password'  => 'mysecretpassword',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
),

//Server/Site 2
'mysql2' => array(
    'driver' => 'mysql',
    'host' => '123.456.789.101',
    'port' => '3306',
    'database' => 'app',
    'username' => 'forge',
    'password' => 'mysecretpassword',
    'charset' => 'utf8',
    'collation' => 'utf8_general_ci',
    'prefix' => '',
    'strict' => false,
    'engine' => null,
),

And then adding this to my model:

protected $connection = 'mysql2';



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2o3DTd8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire