dongyan3018 2016-04-28 04:30
浏览 491
已采纳

SQLSTATE [HY000] [2002]连接尝试失败.. - 尝试从本地连接到远程服务器时

env file:

  1. APP_ENV=local
  2. APP_DEBUG=true
  3. APP_KEY= ...........
  4. DB_HOST=srv3.linuxisrael.co.il
  5. DB_DATABASE= name_of_my_database
  6. DB_USERNAME=moti_winkler
  7. DB_PASSWORD=1234567890
  8. CACHE_DRIVER=file
  9. SESSION_DRIVER=file
  10. QUEUE_DRIVER=sync
  11. MAIL_DRIVER=smtp
  12. MAIL_HOST=mailtrap.io
  13. MAIL_PORT=2525
  14. MAIL_USERNAME=null
  15. MAIL_PASSWORD=null
  16. MAIL_ENCRYPTION=null

Routes.php :

  1. use App\User;
  2. Route::get('/', function(){
  3. User::create(['first_name' => 'moti']);
  4. return view('welcome');
  5. });

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

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

展开全部

  • 写回答

1条回答 默认 最新

  • doudi4014 2016-04-28 05:06
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部