laravel (2/2) QueryException SQLSTATE[HY000] [1049] 未知数据库“homestead”(SQL:从“users”中选择 count(*) 作为聚合,其中“email”=
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44751427/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
(2/2) QueryException SQLSTATE[HY000] [1049] Unknown database 'homestead' (SQL: select count(*) as aggregate from `users` where `email` =
提问by weristsam
I want to try the registration form of laravel where I have to insert my database information in the .env
file.
我想尝试laravel的注册表单,我必须在.env
文件中插入我的数据库信息。
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=blog
DB_USERNAME=root
DB_PASSWORD=admin
In my config/database.php
file I also change the values to my current database
在我的config/database.php
文件中,我还将值更改为当前数据库
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'blog'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'admin'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
But, I get the error that my homestead
database is unknown. I have know idea where the information comes from ? I don't have connect a database with this name in any file? or should there a third file to change?
但是,我收到我的homestead
数据库未知的错误。我知道信息来自哪里?我没有在任何文件中使用此名称连接数据库?还是应该更改第三个文件?
回答by Vishal Varshney
@weristsam You should clear the cache after changing in .env file
@weristsam 您应该在 .env 文件中更改后清除缓存
run the following commands
运行以下命令
php artisan cache:clear
php artisan config:clear
php artisan config:cache
回答by Lawrence E Bosumbe
After successfully modifying the .env file and you're still receiving unknown homestead database, don't stress the thing is Laravel is still reading the previous cache and compiled view. Just clear all by using the following command:
成功修改 .env 文件后,您仍然收到未知的 homestead 数据库,不要强调 Laravel 仍在读取以前的缓存和编译视图。只需使用以下命令清除所有内容:
php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan view:clear