env file:
环境文件:
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');
});
The error i get :
我得到的错误是:
PDOException in Connector.php line 55:
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.
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. usually mysql port (3306) can only be accessed from the private network interface.
这并不令人惊讶。MySQL套接字很少为来自公共接口的连接保持打开状态。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.
即使套接字是打开的,也有太多事情会出错,包括防火墙挡路和简单的超时。
Use SSH tunnel to connect the remote database.
使用SSH隧道连接远程数据库。
More about SSH tunnel and some examples here: http://chxo.com/be2/20040511_5667.html
有关SSH隧道的更多信息和此处的一些示例:http://chxo.com/be2/20040511_5667.html
更多回答
我是一名优秀的程序员,十分优秀!