且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQLSTATE [HY000] [2003]无法连接到"127.0.0.1"(61)错误Laravel 4.1上的MySQL服务器

更新时间:2022-12-02 14:50:53

类似的错误表示服务器本身甚至无法访问.您是否在MAMP中启动MySQL?

An error like that means the server itself is not even reachable. Did you start MySQL in MAMP?

此外,您是如何开始进行MAMP的?使用标准的MySQL 3306端口?还是MAMP用于非管理员的备用端口:8889?

Also, how have you started MAMP? With the standard MySQL 3306 port? Or the alternative port MAMP uses for non-admins: 8889?

我敢打赌您的服务器正在运行,但是正在尝试连接到3306,因此您需要将端口设置为8889.更改您的配置,如下所示:请注意port参数的添加:

I bet your server is running, but is attempting to connect to 3306 so you need to set the port to 8889. Change your config to be like this; note the addition of the port param:

'mysql' => array(
            'driver'    => 'mysql',
            'host'      => '127.0.0.1',
            'port'      => '8889',
            'database'  => 'database',
            'username'  => 'root',
            'password'  => 'root',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
        ),

编辑:我刚刚发现

I just found this question thread that addresses the issue of connecting Laravel to MAMP via port 8889.