Cannot Connect To Local Database Through Local Socket --- Windows 7 x64 #157

Closed
ghost opened this Issue Apr 29, 2011 · 11 comments

Comments

Projects
None yet
7 participants
@ghost

ghost commented Apr 29, 2011

Cannot connect to local database through local socket, when trying to use TCP-IP simply hangs instead of failing.

require 'mysql2'

client = Mysql2::Client.new(:host => "localhost", :socket => "mysql", \
    :username => "root", \
    :password => "root" \
  )

gives the error:

c:/apps/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.7/lib/mysql2/client.rb:42:in
 `connect': Can't connect to MySQL server on 'localhost' (10061) (Mysql2::Error)

        from c:/apps/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.7/lib/mysql2/client.rb:42:in `initialize'
        from test.rb:3:in `new'
        from test.rb:3:in `<main>'

MySQL Workbench connects just fine over mysql socket, double check my.ini file and the socket name is correct.

@xeagle2

This comment has been minimized.

Show comment
Hide comment
@xeagle2

xeagle2 May 17, 2011

Facing the same issue. Is there any option to solve this?

xeagle2 commented May 17, 2011

Facing the same issue. Is there any option to solve this?

@namxam

This comment has been minimized.

Show comment
Hide comment
@namxam

namxam Jun 8, 2011

Can copy that. Too bad that there is no news on the topic :(

namxam commented Jun 8, 2011

Can copy that. Too bad that there is no news on the topic :(

@brianmario

This comment has been minimized.

Show comment
Hide comment
@brianmario

brianmario Jun 16, 2011

Owner

Would you mind giving 0.2.8 a try?

Owner

brianmario commented Jun 16, 2011

Would you mind giving 0.2.8 a try?

@namxam

This comment has been minimized.

Show comment
Hide comment
@namxam

namxam Jun 16, 2011

I will talk to my colleague, but I think we already tried with 0.2.8 and had the exact same problem. For now, we downgraded the project to ruby 1.8.7 with mysql.

namxam commented Jun 16, 2011

I will talk to my colleague, but I think we already tried with 0.2.8 and had the exact same problem. For now, we downgraded the project to ruby 1.8.7 with mysql.

@xeagle2

This comment has been minimized.

Show comment
Hide comment
@xeagle2

xeagle2 Jun 18, 2011

I have checked 0.2.8 version and experienced the same issue unfortunately. Any ideas when it's going to be fixed?

xeagle2 commented Jun 18, 2011

I have checked 0.2.8 version and experienced the same issue unfortunately. Any ideas when it's going to be fixed?

@brianmario

This comment has been minimized.

Show comment
Hide comment
@brianmario

brianmario Jun 18, 2011

Owner

Give 0.2.11 a try?

Owner

brianmario commented Jun 18, 2011

Give 0.2.11 a try?

@xeagle2

This comment has been minimized.

Show comment
Hide comment
@xeagle2

xeagle2 Jun 18, 2011

Interesting, finally it seems to be working to me, at least it doesn't show the connection error again. I will give it another overall try a little bit later, however it looks like we currently have a point to merge working code to the latest branches.

xeagle2 commented Jun 18, 2011

Interesting, finally it seems to be working to me, at least it doesn't show the connection error again. I will give it another overall try a little bit later, however it looks like we currently have a point to merge working code to the latest branches.

@Wardrop

This comment has been minimized.

Show comment
Hide comment
@Wardrop

Wardrop Sep 1, 2011

Does using '127.0.0.1' instead of 'localhost' make any difference? Some software such as I believe MySQL requires an explicit entry for localhost in your hosts file (C:\Windows\System32\drivers\etc\hosts), otherwise it has issues resolving localhost. It's possible that this is causing you problems, thus either try 127.0.0.1, or add "127.0.0.1 localhost" to your hosts file.

Wardrop commented Sep 1, 2011

Does using '127.0.0.1' instead of 'localhost' make any difference? Some software such as I believe MySQL requires an explicit entry for localhost in your hosts file (C:\Windows\System32\drivers\etc\hosts), otherwise it has issues resolving localhost. It's possible that this is causing you problems, thus either try 127.0.0.1, or add "127.0.0.1 localhost" to your hosts file.

@gmena

This comment has been minimized.

Show comment
Hide comment
@gmena

gmena Jan 9, 2012

After a lot of trouble the 10061 error no longer appears after adding an entry for localhost in my hosts file. My current setup is:

  • Windows 7 32 bits
  • MySQL 5.1
  • Ruby 1.8.7
  • mysql2 0.3.11 x86-mingw32

gmena commented Jan 9, 2012

After a lot of trouble the 10061 error no longer appears after adding an entry for localhost in my hosts file. My current setup is:

  • Windows 7 32 bits
  • MySQL 5.1
  • Ruby 1.8.7
  • mysql2 0.3.11 x86-mingw32
@tenderlove

This comment has been minimized.

Show comment
Hide comment
@tenderlove

tenderlove Mar 28, 2012

Collaborator

It seems there is a solution for this. If the problem is still persisting, can someone comment with repro steps, including version of ruby and mysql2 gem (and I'll reopen)?

Thanks for using mysql2!

Collaborator

tenderlove commented Mar 28, 2012

It seems there is a solution for this. If the problem is still persisting, can someone comment with repro steps, including version of ruby and mysql2 gem (and I'll reopen)?

Thanks for using mysql2!

@tenderlove tenderlove closed this Mar 28, 2012

@ehwinter

This comment has been minimized.

Show comment
Hide comment
@ehwinter

ehwinter Jun 3, 2012

Confirmed. Adding (uncommenting)
127.0.0.1 localhost
C:\Windows\System32\drivers\etc\hosts
solved this.
Rails 3.2.2, mysql2 (0.3.11 x86-mingw32), ruby 1.9.3p194 (2012-04-20) [i386-mingw32],
MySql 5.5.24-winx64.msi, mysql-connector-c-6.0.2-win32.msi
Running under windows 7.

Note that I also did a full install on an XP machine where this issue never arose.

ehwinter commented Jun 3, 2012

Confirmed. Adding (uncommenting)
127.0.0.1 localhost
C:\Windows\System32\drivers\etc\hosts
solved this.
Rails 3.2.2, mysql2 (0.3.11 x86-mingw32), ruby 1.9.3p194 (2012-04-20) [i386-mingw32],
MySql 5.5.24-winx64.msi, mysql-connector-c-6.0.2-win32.msi
Running under windows 7.

Note that I also did a full install on an XP machine where this issue never arose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment