4Manuals

  • PDF Cloud HOME

使用php artisan migration的错误是Illuminate \ Database \ QueryException Download

    碳日期差异方法在Laravel 5.7中给出了错误的日期差异 如何使用PHP将https错误状态设置为404,以便可以通过.htaccess文件处理? 通过dropzone laravel通过电子邮件发送多个图像 通过键合并两个数组,并将值附加到另一个数组中 电子邮件字段为空 如何在TCPDF中添加Jameel Noori Nastaleeq字体? 如何取消发布PHP Artisan Laravel模块 使用tomcat调用JavaBridge时获取404 如何在PHP中控制缓存 为什么我在php中的mysqli查询不起作用

我想使用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 个答案:

答案 0 :(得分:0)

检查您的.env文件应位于此位置。示例

DB_HOST=localhost
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

DB_USERNAME和DB_PASSWORD对于您的情况可能有所不同。

答案 1 :(得分:0)

有许多可能导致该错误消息的问题,尽管我认为您只需要在运行迁移时指定此问题即可。

php artisan migrate:fresh

如果它不起作用,请检查您的.env文件是否存在数据库连接,请确保数据库属性为“ laravel”(根据您显示给我们的错误消息)

答案 2 :(得分:0)

执行以下步骤。 配置.env文件后运行以下命令

php artisan config:cache
php artisan config:clear
php artisan cache:clear



Similar searches
    作曲家缓存不适用于bitbucket管道构建 如何将多个图像作为输入输入到卷积神经网络 如何从“ mdb-select”列表中选择选项 组中每一行的Dplyr时差 Samsung RB215ACBP Refrigerator User Manual