1. Home
  2. Server
  3. Defect #11685: Can't connect to MySQL server on 'localhost ...

Defect #11685: Can't connect to MySQL server on 'localhost ...

Rsdaa 21/10/2021 105

Defect #11685

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

由 Giovanni Junior 在 大约 9 年 之前添加. 更新于 超过 8 年 之前.

状态:Closed开始日期:优先级:Normal计划完成日期:指派给:-% 完成:

0%

类别:Documentation目标版本:-Resolution:InvalidAffected version:

描述

I got the error "Can't connect to MySQL server on 'localhost' (10061)" when trying to execute migrations on my old Redmine database.

After lots of searching I found this page, who solved my problem: https://github.com/brianmario/mysql2/issues/157

The problem seems to be that Mysql2 adapter doesn't understand the hostname "localhost". To solve it, I had to replace "localhost" with "127.0.0.1" in database.yml.

I think the RedmineInstall guide should warn users to use "127.0.0.7" instead of "localhost" when using the Mysql2 adapter.

My configuration:Windows 7 64 bitsMySQL 5.5 (or 5.1) 64 bitsMySQL Connector C 6.0.2 32 bitsRuby 1.9.3 32 bitsMysql2 gem, version 0.3.11

历史记录

类别 从 Website (redmine.org) 变更为 Documentation 状态 从 New 变更为 Closed 指派给 已删除 (Jean-Philippe Lang) 优先级 从 High 变更为 Normal Resolution 被设置为 Invalid

Actually the problem seems to be that the "localhost" entry has been removed from your hosts file, probably by MS Windows Defender.

Sorry I close this issue as it is not a RM one, please reopen if you're absolutly sure that this is due to the mysql2 adapter unable to resolve localhost and provide a valid reference to the adapter issue.

I didn't intend to point out a problem with Redmine itself. I just wanted to help you improve the documentation for users trying to install it, in order to keep the experience as painless as it had always been for me, and to prevent other users from wasting time as I did.

Even if what I described is not a legitimate "issue" of the mysql2 adapter, I still think it could be mentioned in the section of RedmineInstall dedicated specifically to Windows: http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Notes-on-Windows-installation

I'm not reopening this issue, as it's your responsibility to decide what deserves to be documented.

One more interesting thing: the former mysql adapter works fine with "localhost" on the same environment, as well as other clients. The fact that I had this error only with the mysql2 adapter made the problem trickier.

Giovanni Junior wrote:

One more interesting thing: the former mysql adapter works fine with "localhost" on the same environment, as well as other clients. The fact that I had this error only with the mysql2 adapter made the problem trickier.

Did you have a localhost mapping in your hosts file?

I read some instructions which mentioned the hosts file, but ignored them, as I never had to edit that file before and "127.0.0.1" was an easier (and less intrusive) solution.

Everything in my hosts file is commented out (I've never changed it).

Giovanni Junior wrote:

I read some instructions which mentioned the hosts file, but ignored them, as I never had to edit that file before and "127.0.0.1" was an easier (and less intrusive) solution.

Everything in my hosts file is commented out (I've never changed it).

Ok, googling a bit more, here's a different theory: by default, localhost is commented out in W7+ hosts file1 and IPV6 is the default2. As "mysql2 gem does no support IPV6 addresses3, connection won't be established.Then I can only assume that mysql gem supports IPV6 adresses.

If you could confirm it (simply by pinging localhost), it might be worse to add a note in guide about this indeed.BTW, Redmine guide is editable by everyone.

Ping localhost targets "::1:", meaning IPV6 is being used.

I can't see any icons or links to edit wiki pages...

I just bang my head for hours trying to figure why I was getting error 10061 with mysql2 on Windows 7 and it turns out the solution was to replace localhost by 127.0.0.1 in database.yml.

I neither can't find how to edit the wiki to add a note about this, so I reopen the issue hoping someone will edit the wiki.

状态 从 Reopened 变更为 Resolved

Etienne Massip wrote:

BTW, Redmine guide is editable by everyone.

Not exactly, the page RedmineInstall is locked.

I added the relevant information for Win7+ users from this issue to the wiki page.

导出AtomPDF


PREV: How To Configure an Apache Virtual Host

NEXT: How to Enable Apache Virtual Host in Windows 10. - Linux ...

Popular Articles

Hot Articles

Navigation Lists

Back to Top