[英]How to Change Database in Laravel 5.7
I created a new project and set up my database accordingly in the .env
file.我创建了一个新项目并在.env
文件中相应地设置了我的数据库。
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=8889
DB_DATABASE=example_olddb
DB_USERNAME=example_user
DB_PASSWORD=example_password
After much development, I want to change my database to a new database.经过多次开发,我想将我的数据库更改为新数据库。 So I edited the '.env' file again.所以我再次编辑了“.env”文件。
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=8889
DB_DATABASE=example_newdb///<-- change here
DB_USERNAME=example_user
DB_PASSWORD=example_password
However, I got the following error.但是,我收到以下错误。
SQLSTATE[HY000] [1049] Unknown database 'example_olddb' SQLSTATE[HY000] [1049] 未知数据库“example_olddb”
It used to work in Laravel 5.5
and 5.6
, but not now in 5.7
.它曾经适用于Laravel 5.5
和5.6
,但现在不适用于5.7
。 I tried to clear the cache, but same error persists.我试图清除缓存,但同样的错误仍然存在。 How can I resolve this issue?我该如何解决这个问题?
.env
编辑完成后,您可以使用以下 artisan 命令清除配置缓存: php artisan config:cache
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.