【问题标题】:I can't access database and migrate in laravel project using port number 3306 for mysql我无法使用 mysql 的端口号 3306 访问数据库并在 laravel 项目中迁移
【发布时间】:2019-02-27 12:07:11
【问题描述】:

The first picture is the database config in .env file and the port number is 3306

The second picture is the database config in /config/database.php file

The third picture is the database config in mysql workbench

.env文件中端口号设置为3306时无法迁移模型和访问数据库,设置为33060则可以访问。

它生成错误“Illuminate\Database\QueryException : SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)”当我尝试运行“php artisan migrate”时。

我尝试了很多方法,但在使用端口 3306 时仍然遇到同样的问题。

【问题讨论】:

  • 您必须将DB_HOST 设置为您可以访问vagran 框的IP 地址,检查您的vagrantfile ip_address 设置为哪个值
  • 我搜索了项目目录,找到了三个vagrantfile,但没有一个包含“ip_address”。
  • 可以通过终端访问vagrant box吗?
  • 是的,我可以在终端中使用 vagrant 命令,例如“vagrant up”。
  • 输入你的 vagrantfile config.vm.network "public_network", ip: "192.168.1.10" 然后在终端中运行 vagran reload

标签: mysql laravel vagrant


【解决方案1】:

Vagrant box 不会像您在 .env 文件中指定的那样在 localhost(127.0.0.1) 上运行,您必须指定 ip_address,您可以通过输入 vagrantfile 来访问 vagrant

config.vm.network "public_network", ip: "192.168.1.10"

之后在终端中运行vagran reload

【讨论】:

    猜你喜欢
    • 2014-06-09
    • 1970-01-01
    • 2021-01-25
    • 2019-07-19
    • 2020-03-15
    • 2012-11-16
    • 2011-09-02
    • 2014-07-28
    • 1970-01-01
    相关资源
    最近更新 更多