Skip to content

How to make a multi database connection in laravel ? #5

Closed Answered by shazeedul
iqbalhasandev asked this question in Q&A
Discussion options

You must be logged in to vote

Configure Database Connections in config/database.php:
Open the config/database.php file and define your database connections in the connections array. You can name your connections whatever you like. For example, let's create two connections named "mysql" and "pgsql":

'connections' => [
    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        // ...
    ],
    'pgsql' => [
        'driver' => 'pgsql',
        'host' => env('DB_PG_HOST', '127.0.0.1'),
        'database' => env('DB_PG_DATABASE', 'forge'

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@iqbalhasandev
Comment options

iqbalhasandev Oct 5, 2023
Maintainer Author

Answer selected by iqbalhasandev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested laravel
2 participants