连接到带有Homestead问题的Sequel Pro [英] Connecting to Sequel Pro with Homestead issues

查看:63
本文介绍了连接到带有Homestead问题的Sequel Pro的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里和GitHub上,我一直在检查很多有关此问题的答案,但是无论我尝试如何,总有问题.我也不明白为什么有时使用相同的凭据可以连接其他时间,但我什至无法做到这一点.

I have been checking out a lot of answers here and on GitHub regarding this issue, but whatever I try there is always something wrong. I also don´t get why with the same credentials sometimes I am able to connect other times I am not even able to do that.

所以现在我收到以下错误:

So right now I get the following error:

"SQLSTATE [HY000] [2002] php_network_getaddresses:getaddrinfo失败:提供的节点名或服务名,或者未知

"SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known

我无法连接:

我的.env凭据:

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

我的database.php

My database.php

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST'),
            'port' => env('DB_PORT'),
            'database' => env('DB_DATABASE'),
            'username' => env('DB_USERNAME'),
            'password' => env('DB_PASSWORD'),
            'unix_socket' => env('DB_SOCKET'),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => false,
            'engine' => null,
        ],

...对于标准连接,我使用192.168.10.10作为主机.

...and for the standard connection, I use 192.168.10.10 for the host.

推荐答案

我认为您的问题出在 DB_HOST 参数上.我提供了完整的解释.您的修补程序很可能是最后一段的一部分!

I think your issue is with the DB_HOST parameter. I included a full explanation. Your fix is likely part of the final paragraph!

Laravel附带了一个 .env.example ,配置为直接连接到Homestead MySQL.假设您正在Homestead中运行所有程序,并且Homestead配置正确,则您应该能够使用以下数据库配置成功连接.

Laravel ships with a .env.example configured to connect to the Homestead MySQL out of the box. Assuming you are running everything in Homestead, and Homestead is configured properly, you should be able to use the following database configuration to connect successfully.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

如果您尝试从Homestead外部连接到Homestead数据库,Laravel文档将介绍如何执行此操作.您可以在此处中查看.

If you are trying to connect to the Homestead database from outside of Homestead, the Laravel documentation describes how you can do that as well. You can check that out here.

基本上,您需要做的是作为主机连接到 127.0.0.1 作为主机,但是使用不同的端口(与 3306 相对.)对于MySQL,Homestead公开了一个您应该尝试连接的端口 33060 .对于Sequel Pro,这应该可以解决您的问题!

Essentially what you need to do is connect to 127.0.0.1 as a host but use a different port (as opposed to 3306.) For MySQL, Homestead exposes a port 33060 that you should try to connect to instead. For Sequel Pro this should fix your issue!

这篇关于连接到带有Homestead问题的Sequel Pro的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆