[英]SQLSTATE[HY000] [2002] A connection attempt failed.. - When attempting to connect from Local to remote server
env file: .env 文件:
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 :路线.php :
use App\User;
Route::get('/', function(){
User::create(['first_name' => 'moti']);
return view('welcome');
});
The error i get :我得到的错误:
PDOException in Connector.php line 55: Connector.php 第 55 行中的PDOException :
SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. SQLSTATE[HY000] [2002] 连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接的主机没有响应而建立的连接失败。
My problem is that:我的问题是:
I'm trying to connect from my computer - to my remote MySQL server我正在尝试从我的计算机连接到我的远程 MySQL 服务器
And I don't understand why it doesn't work ?我不明白为什么它不起作用?
What should I do to connect ?我应该怎么做才能连接?
What am I missing ?我错过了什么?
I am using Laravel 5.1我正在使用 Laravel 5.1
Hardly a surprise.难怪。 The mysql socket is rarely if ever left open for connections from the public facing interface. mysql 套接字很少为来自面向公众的接口的连接打开。 usually mysql port (3306) can only be accessed from the private network interface.通常mysql端口(3306)只能从私有网络接口访问。
Even if the socket was open, there are so many things that that go wrong including firewalls getting in the way and simple timeouts.即使套接字是打开的,也会出现很多问题,包括防火墙阻碍和简单的超时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.