mysql database connection with laravel

135 Views Asked by At

I have the following problem, when I configure my database in the .env file and carry out the migrations, I see that they are carried out but in a different DB than the one I have configured, and the truth is that I do not know why, I attach images.

mi archivo .env, apunta mi base de datos prueba2:

enter image description here

but the migration is done to my other database bdperformlead:

enter image description here

1

There are 1 best solutions below

0
Hasan Ali Haolader On

check some configuration

config > database.php

'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'read' => [
                'host' => [
                    env('SLAVE_DB_HOST', '127.0.0.1'),
                ],
                'port' => env('SLAVE_DB_PORT', '3306'),
                'database' => env('SLAVE_DB_DATABASE', 'forge'),
                'username' => env('SLAVE_DB_USERNAME', 'forge'),
                'password' => env('SLAVE_DB_PASSWORD', ''),
            ],
            'write' => [
                'host' => [
                    env('DB_HOST', '127.0.0.1'),
                ],
                'port' => env('DB_PORT', '3306'),
                'database' => env('DB_DATABASE', 'forge'),
                'username' => env('DB_USERNAME', 'forge'),
                'password' => env('DB_PASSWORD', ''),
            ],
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8',
            'collation' => 'utf8_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'),
            ]) : [],
        ],

if database name get using .env, check .env properly and run php artisan optimize:clear