【问题标题】:Why must i change my DB_PORT to 33060 to run migration and then have to change it back to 3306? Laravel6为什么我必须将 DB_PORT 更改为 33060 才能运行迁移,然后必须将其更改回 3306? Laravel6
【发布时间】:2019-11-09 08:21:03
【问题描述】:

当我尝试使用 DB_PORT=3306 进行迁移时出现此错误

SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')

所以我必须将 DB_PORT 更改为 DB_PORT=33060

然后我得到这个错误

SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `users` where `id` = 1 limit 1)

当我尝试使用此代码加载视图时

<div>
                    @foreach($users as $user)
                        {{$user}}
                        @endforeach
                </div>

并且必须将我的端口改回 DB_PORT=3306 使其正常运行。

我正在使用 MySQL Workbench,这是一个大问题,因为我开始处理队列/通知并运行类似的命令 php artisan migratephp artisan queue:work 我必须进入我的 .env 并更改我的端口才能处理队列,然后我必须更改端口才能加载视图而不会出现错误,如果视图使用任何从控制器传递的变量/数据。

【问题讨论】:

  • 是什么让您认为需要更改端口?

标签: mysql-workbench laravel-6


【解决方案1】:

问题在于,虽然更改 DB_PORT 确实允许我运行诸如 migrate 和 queue:work 之类的命令,但我从未意识到我的 PHPStorm 终端实际上​​并没有在我的 vagrant 环境中工作。我需要在运行命令时通过 ssh 连接到 VM。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-24
    • 2016-03-02
    • 2011-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多