SQLSTATE[HY000] [2002] 连接尝试失败.. - 尝试从本地连接到远程服务器时 [英] SQLSTATE[HY000] [2002] A connection attempt failed.. - When attempting to connect from Local to remote server

查看:51
本文介绍了SQLSTATE[HY000] [2002] 连接尝试失败.. - 尝试从本地连接到远程服务器时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境文件:

APP_ENV=local
APP_DEBUG=true
APP_KEY= ...........

DB_HOST=srv3.linuxisrael.co.il
DB_DATABASE= name_of_my_database
DB_USERNAME=moti_winkler
DB_PASSWORD=1234567890

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

Routes.php :

Routes.php :

use App\User;

Route::get('/', function(){
    User::create(['first_name' => 'moti']);
    return view('welcome');
});

我得到的错误:

PDOException in Connector.php 第 55 行:

PDOException in Connector.php line 55:

SQLSTATE[HY000] [2002] A连接尝试失败,因为连接方没有正确一段时间后响应,或建立连接失败因为连接的主机未能响应.

我的问题是:

我正在尝试从我的计算机连接到我的远程 MySQL 服务器

I'm trying to connect from my computer - to my remote MySQL server

我不明白为什么它不起作用?

And I don't understand why it doesn't work ?

我应该怎么做才能连接?

What should I do to connect ?

我错过了什么?

我使用的是 Laravel 5.1

I am using Laravel 5.1

推荐答案

不足为奇.mysql 套接字很少为来自面向公众的接口的连接打开.通常mysql端口(3306)只能从私网接口访问.

Hardly a surprise. The mysql socket is rarely if ever left open for connections from the public facing interface. usually mysql port (3306) can only be accessed from the private network interface.

即使套接字是打开的,也会出现很多问题,包括防火墙阻碍和简单的超时.

Even if the socket was open, there are so many things that that go wrong including firewalls getting in the way and simple timeouts.

这篇关于SQLSTATE[HY000] [2002] 连接尝试失败.. - 尝试从本地连接到远程服务器时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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