我想使用 首先,我使用了 我该怎么办? 答案 0 :(得分:0) 检查您的.env文件应位于此位置。示例 答案 1 :(得分:0) 有许多可能导致该错误消息的问题,尽管我认为您只需要在运行迁移时指定此问题即可。 如果它不起作用,请检查您的.env文件是否存在数据库连接,请确保数据库属性为“ laravel”(根据您显示给我们的错误消息) 答案 2 :(得分:0) 执行以下步骤。
配置.env文件后运行以下命令PHP artisan migrate
更新数据库。PHP artisan make: auth
并成功了,但是当我使用migrate
时出现了以下错误C:\memory>php artisan migrate
Illuminate\Database\QueryException : SQLSTATE[HY000] [1049] Unknown database 'laravel' (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
at C:\memory\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[HY000] [1049] Unknown database 'laravel'")
C:\memory\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel", "root", "", [])
C:\memory\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
Please use the argument -v to see more details.
3 个答案:
DB_HOST=localhost
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
DB_USERNAME
和DB_PASSWORD
对于您的情况可能有所不同。php artisan migrate:fresh
php artisan config:cache
php artisan config:clear
php artisan cache:clear