Local and remote Database connection

Posted 1 year ago by venkat1806

Hi Everyone,

For my application I use MySQL in localhost (LAMP) to manage data, input by users.

In the same application, I have a requirement to fetch data from a remote SQLsrv too.

Kindly assist me to achieve it

.env file configuration

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=DB
DB_USERNAME=user1
DB_PASSWORD=

Configured my config/database.php with

    'default' => env('DB_CONNECTION', 'mysql'),

        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'host' => env('DB_HOST', '10.10.90.1'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'project1'),
            'username' => env('DB_USERNAME', 'user1'),
            'password' => env('DB_PASSWORD', 'psswd'),
            'charset' => 'utf8',
            'prefix' => '',
        ],

    ],

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.