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

I have this error when I use php artisan migrateLaravel in my project.

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

this is my file database.php:

'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 helped.

+4
source share
3 answers

It clearly states that there is no such database named previous_db_name .

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

. env Laravel, , , .

+7

Laravel 5.x

  • .env
  • .database.php config
+3

specify the name of your database in the .env file.

0
source

Source: https://habr.com/ru/post/1615712/


All Articles