首页 > 解决方案 > 从 git 克隆后 Laravel 数据库名称不正确

问题描述

我使用 ssh 密钥从 git 克隆了我的项目,现在我的 env 文件已更改。无论我尝试什么工匠命令,它一直说我的数据库名称错误。

有人知道我应该填写什么吗?我忘记了上一个 env 文件中的数据库名称是什么。我失去了另一个项目。

SQLSTATE[HY000] [1049] Unknown database 'laravel' (SQL: select * from `permission`)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:678
    674▕         // If an exception occurs when attempting to run a query, we'll format the error
    675▕         // message to include the bindings with SQL, which will make this exception a
    676▕         // lot more helpful to the developer instead of just the database's errors.
    677▕         catch (Exception $e) {
  ➜ 678▕             throw new QueryException(
    679▕                 $query, $this->prepareBindings($bindings), $e
    680▕             );
    681▕         }
    682▕ 

  • Database name seems incorrect: You're using the default database name `laravel`. This database does not exist.
    
    Edit the `.env` file and use the correct database name in the `DB_DATABASE` key. 

这是我的环境文件的一部分:

PP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=root

标签: laravelgitlaravel-8

解决方案


检查 config/database.php 连接一些开发人员编写他们的数据库配置


推荐阅读