Defect #11685
closedCan't connect to MySQL server on 'localhost' (10061)
0%
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
Updated by Etienne Massip over 12 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.
Updated by Giovanni Junior over 12 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.
Updated by Giovanni Junior over 12 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.
Updated by Etienne Massip over 12 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?
Updated by Giovanni Junior over 12 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).
Updated by Etienne Massip over 12 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.
Updated by Giovanni Junior over 12 years ago
Ping localhost targets "::1:", meaning IPV6 is being used.
I can't see any icons or links to edit wiki pages...
Updated by Martin Dubé about 12 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.
Updated by Jan Niggemann (redmine.org team member) about 12 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.
Updated by Jan Niggemann (redmine.org team member) almost 12 years ago
- Status changed from Resolved to Closed