Rails development - Can't connect to MySQL server on 'localhost' (10061)

前端 未结 7 692
轻奢々
轻奢々 2020-12-30 04:39

I\'m a Rails developer newbie using MySQL as the database. I can successfully connect to MySQL using the command:

MySQL -u macDaddy -p

at t

7条回答
  •  有刺的猬
    2020-12-30 05:03

    My best guess is that the machine, which you indicated as Windows, has IPv6 networking enabled. Thus when you try to go to localhost, it is resolving to "::1". This is in fact the local machine, however, default MySQL installs normally have bind-address set to 127.0.0.1, which would cause localhost to fail in this setup.

    You might be able to verify this by running ping localhost from the command prompt, and seeing if you get a response like:

     Reply from ::1: time<1ms
    

    To fix this, you can change your config to specify:

     host: 127.0.0.1
    

    Alternately, you can change MySQL's configuration to allow a different bind-address, e.g. localhost instead of 127.0.0.1.

提交回复
热议问题