Laravel迁移未知数据库 [英] Laravel migrate unknown database

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

问题描述

我在使用laravels php artisan migrate命令时遇到一些错误,当我尝试进行迁移时,它会不断抛出错误,例如,未知的数据库数据库名称"我检查了我的数据库配置文件,甚至将其复制到另一个项目中,并且该文件在该项目中运行良好,我尝试使用composer dump-autoload命令,但也未能解决问题.请多谢我,如果有人帮忙,我将不胜感激,因为这是一个新项目,即使我不能在最后期限前浪费一分钟,也要提前感谢!

当我将CD放入项目文件夹时,从终端运行的命令是

.

  php artisan迁移 

这是我得到的错误.

  [PDOException]SQLSTATE [42000] [1049]未知数据库'[gicfamily4]' 

解决方案

  [PDOException]SQLSTATE [42000] [1049]未知数据库'[gicfamily4]' 

这是一个MySQL错误,表明您环境的database.php配置文件中的配置错误(数据库名称中拼写有误) 或数据库 gicfamily4 根本没有您连接到的数据库服务器上不存在.

再次验证您的连接信息.如果可能,请尝试使用您的database.php文件中包含的完全相同的信息(通过复制和粘贴)尝试从命令行连接到mysql服务器:

  $ mysql -u< database.php文件中的用户名>-p -h< database.phpfile中的数据库主机>输入密码:<从database.php文件中粘贴密码>mysql>使用gicfamily4; 

我怀疑您会得到与上述完全相同的错误.

I am having some errors with laravels php artisan migrate command, when I try to migrate, it keeps throwing errors saying, unknown database 'database name' I have checked my database configure file and even copied to a different project and it works perfectly there, I have tried composer dump-autoload command but that didn't solve the problem either. Please I will really appreciate if someone helps, since this is a new project and can't afford to lose even a minute to my deadline, thanks in advance!

The command I run from the terminal while I have CD'ed into the project folder is.

php artisan migrate

This is the error I get.

[PDOException]
SQLSTATE[42000] [1049] Unknown database '[gicfamily4]'

解决方案

[PDOException]
SQLSTATE[42000] [1049] Unknown database '[gicfamily4]'

This is a MySQL error and is indicative of either a misconfiguration in your environment's database.php config file (misspelling in the database name) or the database gicfamily4 simply doesn't exist on the database server you are connecting to.

Verify your connection information again. If possible, try to attempt to connect to the mysql server from the command line using the exact same information contained in your database.php file (via copy and paste):

$ mysql -u <username from database.php file> -p -h <database host from database.phpfile>
Enter Password: <paste password from database.php file>

mysql> use gicfamily4;

I suspect you will get the exact same error as above.

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

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