【问题标题】:Laravel-8:php artisan migrate not workingLaravel-8:php 工匠迁移不起作用
【发布时间】:2021-02-21 12:57:56
【问题描述】:

我尝试运行命令:php artisan migrate,但它给了我以下错误。

错误:

   Illuminate\Database\QueryException 

  SQLSTATE[HY000]: General error: 1449 The user specified as a definer ('mysql.infoschema'@'localhost') does not exist (SQL: select * from information_schema.tables where table_schema = test and table_name = migrations and table_type = 'BASE TABLE')

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

我还在我的 mac 上使用 Sequel Pro 创建了一个数据库,但是当我创建一个数据库时,我不确定它是否按照预期的方式创建。

设置如下:

host id: 127.0.0.1
username: root

.env 中的设置是:

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

【问题讨论】:

  • 奇怪的是它试图使用mysql.infoschema 作为用户。如果您使用的是 linux 或 Mac 机器,请从根目录尝试此操作以查看该字符串的来源:grep -R 'mysql.infoschema' * .*
  • 输出:./storage/logs/laravel.log:[2020-11-10 09:23:34] local.ERROR: SQLSTATE[HY000]: General error: 1449 The user specified as a定义者 ('mysql.infoschema'@'localhost') 不存在 (SQL: select * from information_schema.tables where table_schema = test and table_name = migrations and table_type = 'BASE TABLE') {"exception":"[object] (照亮\\数据库\\查询异常(代码:HY000):SQLSTATE [HY000]:
  • 一般错误:1449 指定为定义者的用户 ('mysql.infoschema'@'localhost') 不存在(SQL: select * from information_schema.tables where table_schema = test and table_name = migrations and table_type = 'BASE TABLE') 在 /Users/akansha/Desktop/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:671)

标签: php mysql laravel-8 sequelpro


【解决方案1】:

我一次又一次地尝试迁移 所以只需查看文件 .env 并禁用注释 DB_HOST= mysql 并启用 DB_HOST=127.0.0.1 现在再次尝试将终端 php artisan 迁移,所以看起来一切正常!

【讨论】:

    猜你喜欢
    • 2015-12-18
    • 2018-09-24
    • 2018-09-26
    • 1970-01-01
    • 2016-04-16
    • 2013-02-05
    • 1970-01-01
    • 2018-12-02
    • 1970-01-01
    相关资源
    最近更新 更多