在laravel中安装迁移时出错

时间:2016-03-04 04:27:06

标签: php laravel cmd

我已更改/config/database.php中的所有配置,而.env在输入

时仍然在命令提示符中出现错误

php artisan migrate:install

错误是:

  

[invalidArgumentException]

     

数据库[mysql]未配置

这是.env

APP_ENV=local
APP_DEBUG=true
APP_KEY=aqk5XHULL8TZ8t6pXE43o7MBSFchfgy2

DB_HOST=localhost
DB_DATABASE=larashop
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCR

但是我可以使用以下方法创建数据库:

php artisan make:migration employees

1 个答案:

答案 0 :(得分:0)

您的.env文件和/config/database.php文件应该遵循

<强> .ENV

    DB_HOST=localhost
    DB_DATABASE=your_db_name
    DB_USERNAME=your_db_user_name
    DB_PASSWORD=your_password

<强> /config/database.php

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

另请尝试php artisan migrate