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

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

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 :

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

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 13: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.

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!