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

查看:53
本文介绍了Laravel SQLSTATE [HY000] [1049]未知数据库'previous_db_name'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Laravel项目中使用php artisan migrate时出现此错误.

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

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

这是我的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 was not helpful.

推荐答案

它显然提到没有名为 previous_db_name 的数据库.

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

从看来, database.php 文件不是变量的来源.

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

检查Laravel安装文件夹中的 .env 文件,以查看是否那是您错误指定的数据库名称.

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

这篇关于Laravel SQLSTATE [HY000] [1049]未知数据库'previous_db_name'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆