In some particular case, you might want to use multiple dabase for your Laravel application. To achieve this Laravel provides a very convenient way. To add database follow the steps provided below

Go to config/database.php and under connections key add you new database with different key. In this example I am assuming that you are trying to add new MySQL database. To add new database copy existing mysql connection settings and paste it one more time with different key like like shown below

'mysql_2' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST_2', ''),
            'port' => env('DB_PORT_2', '3306'),
            'database' => env('DB_DATABASE_2', 'forge'),
            'username' => env('DB_USERNAME_2', 'forge'),
            'password' => env('DB_PASSWORD_2', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],

Final step here is to add database detail on you .env file so that Laravel can connect to added database. In this example my environment key are as follows


Fill in the database detail in .env file and you are good to go.

How to use this connection

In you config/database.php default database is set with default key as given below

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

If you want to use added database as default, change the key DB_CONNECTION in .env file and give it the key you have give for new database above. If you are planning to use your added database as secondary, you can access that database and perform operations there as shown in below code example

$users = DB::connection('mysql_2')->select("SELECT * FROM users");

For more information refer to Laravel documentation here.