Laravel; "SQLSTATE [HY000] [2002]连接被拒绝". [英] Laravel; "SQLSTATE[HY000] [2002] Connection refused"

查看:401
本文介绍了Laravel; "SQLSTATE [HY000] [2002]连接被拒绝".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在OSX主机上设置了Homestead 2.0,并使用了Sequel Pro.

I set up homestead 2.0 on OSX host and using Sequel Pro.

我可以进行迁移并确认是否已在Sequel Pro中迁移了数据,所以看来数据库连接没有问题.

I can do migration and confirm that data are migrated in Sequel Pro, so it looks like no problem about DB connection.

但是一旦我尝试从Laravel 4.2应用程序获取数据,它就无法检索数据并出现以下错误.

But once I try to fetch data from Laravel 4.2 app, it fails to retrieve data and get following error.

PDOException (2002) 
SQLSTATE[HY000] [2002] Connection refused

这是我的mysql配置.

Here is my mysql configuration.

'mysql' => array(
            'driver'    => 'mysql',
            'host'      => '127.0.0.1',
            'port'      => '33060',
            'database'  => 'homestead',
            'username'  => 'homestead',
            'password'  => 'secret',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => ''

续集专业设置与上面相同,

Sequel pro setting is same above,

Name: 127.0.0.1    
Host: 127.0.0.1
Username: homestead
Password: secret
Database:     
Port: 33060

我尝试将主机名更改为"localhost",宅基地破坏并启动,但是没有任何工作. 为什么??任何建议都会有所帮助.

I tried change host name to 'localhost', homestead destroy and up, but No work. Why?? Any suggestion helps.

推荐答案

我遇到了完全相同的问题,我不确定为什么会这样. 但是更改

I had exactly the same issue and I'm not sure why this happens. However changing

'host'      => '127.0.0.1',

'host'      => 'localhost',

为我工作.总是比我们期望的要简单!

worked for me. Always simpler than what we expect!

这篇关于Laravel; "SQLSTATE [HY000] [2002]连接被拒绝".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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