Martin Christopher
Martin Christopher

Reputation: 409

Unable to change laravel database

So first thing first i've created migration tables and it successfully migrated and seeded. i've change the .env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=jj
DB_USERNAME=root
DB_PASSWORD=

i've tried to change the database.php

'mysql' => [
        'driver' => 'mysql',
        'url' => env('DATABASE_URL'),
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'jj'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', ''),
        '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'),
        ]) : [],
    ],

but i'm still unable to login. the error says SQLSTATE[HY000] [1049] Unknown database 'laravel' (SQL: select * from `users` where `username` = admin limit 1) even though i've migrated and seeded the database

Upvotes: 1

Views: 773

Answers (1)

The Sammie
The Sammie

Reputation: 1248

If the configuration looks okay and you are 100% certain that MySQL is running, you might want to clear the configs and caches.

php artisan config:clear

php artisan cache:clear

Try the config one and then the cache if the problem isn't resolved by the first command. You can read more about the commands here

Upvotes: 2

Related Questions