Laravel SQLSTATE [HY000] [1049]未知数据库'previous_db_name'

I have this error when i use php artisan migrate in my Laravel project.

[PDOException]
SQLSTATE[HY000] [1049] Unknown database 'previous_db_name'

this is my database.php file :

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

    'mysql' => [
        'driver'    => 'mysql',
        'host'      => env('DB_HOST', 'localhost'),
        'database'  => env('DB_DATABASE', 'current_db_name'),
        'username'  => env('DB_USERNAME', 'root'),
        'password'  => env('DB_PASSWORD', ''),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],
],

I saw this error in this question and this question but none of them was not helpful.

It clearly mentions that there's no such database named previous_db_name.

From what it seems the database.php file is not where the variable is from.

Check the .env file in your Laravel installation folder to see if that's the database name that you have wrongly specified.

In Laravel 5.x You should define the DB Details in two files

  1. .env file in the project folder
  2. .database.php file inside config folder

set your database name in .env file too.

I know, it is super late but for people like me, new in laravel and following tutorial from artisansweb. Note that, migrate will not create your database. Rather, it will just create all the tables. Assuming, you have set up your .env file. Now the important part is create the database and users (if you decided to go with custom users) manually. Then, do the php artisan migrate command

hope that helps.