问题描述
当我使用php artisan migrate
时,出现错误SQLSTATE[42000] [1049] Unknown database 'databaseName'
.
when I use php artisan migrate
, i get the error SQLSTATE[42000] [1049] Unknown database 'databaseName'
.
但是数据库确实存在!我什至尝试返回终端,登录mysql并再次创建数据库,它说数据库已经存在!
But the database DOES exists! I even tried going back into terminal, logged into mysql and created the database again, and it said that database already exists!
这为什么会给我这个错误?
Why is this giving me this error?
推荐答案
在您的app/config/database.php
文件中,将默认值从databaseName
更改为您要在应用程序中尝试使用的真实数据库名称,如下所示(对于mysql
驱动程序):
In your app/config/database.php
file change the default value from databaseName
to a real database name that you are trying to use in your application, something like this (for mysql
driver):
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'your database name', //<-- put the database name
'username' => 'your user name',
'password' => 'your password',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
这篇关于Laravel Migration-说未知数据库,但已创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!