Project

General

Profile

Actions

Defect #11685

closed

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

Added by Giovanni Junior over 11 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Documentation
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

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 bits
MySQL 5.5 (or 5.1) 64 bits
MySQL Connector C 6.0.2 32 bits
Ruby 1.9.3 32 bits
Mysql2 gem, version 0.3.11

Actions #1

Updated by Etienne Massip over 11 years ago

  • Category changed from Website (redmine.org) to Documentation
  • Status changed from New to Closed
  • Assignee deleted (Jean-Philippe Lang)
  • Priority changed from High to Normal
  • Resolution set to 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.

Actions #2

Updated by Giovanni Junior over 11 years ago

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.

Actions #3

Updated by Giovanni Junior over 11 years ago

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.

Actions #4

Updated by Etienne Massip over 11 years ago

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?

Actions #5

Updated by Giovanni Junior over 11 years ago

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).

Actions #6

Updated by Etienne Massip over 11 years ago

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.

1 http://serverfault.com/questions/4689/windows-7-localhost-name-resolution-is-handled-within-dns-itself-why

2 http://www.victor-ratajczyk.com/post/2012/02/25/mysql-fails-to-resolve-localhost-disable-ipv6-on-windows.aspx

3 https://github.com/brianmario/mysql2/issues/279

Actions #7

Updated by Giovanni Junior over 11 years ago

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

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

Actions #8

Updated by Martin Dubé over 11 years ago

  • Status changed from Closed to Reopened

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.

Actions #9

Updated by Jan Niggemann (redmine.org team member) over 11 years ago

  • Status changed from Reopened to 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.

Actions #10

Updated by Jan Niggemann (redmine.org team member) over 11 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF