# Cygwin RoR + Windows MySQL Binary == nil

**URL:** <https://www.ruby-forum.com/t/cygwin-ror-windows-mysql-binary-nil/112485>\
**Category:** Rails\
**Created:** [August 20, 2007, 3:06am UTC](https://www.ruby-forum.com/t/cygwin-ror-windows-mysql-binary-nil/112485 "2007-08-20T03:06:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcloutman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dcloutman](https://www.ruby-forum.com/u/dcloutman)\
**Post date:** [August 20, 2007, 3:06am UTC](https://www.ruby-forum.com/t/cygwin-ror-windows-mysql-binary-nil/112485/1 "2007-08-20T03:06:25Z")

</div>

Hi folks. I’m just learning RoR, and I’m trying to get my development  
environment up and running on my Windows machine. I am working through  
Patrik Lenz’s book from Sitepoint, but am getting stuck because of the  
esoteric way I set things up on my machine.

I already had the Ruby interpreter on my machine through Cygwin, so I  
thought it would be simpler to install the gem manager, and then all  
the related modules through Cygwin. Most of my web applications run in  
a Linux environment, anyway, so I’m comfortable with this approach,  
and it seemed to work pretty well.

Now here’s the tricky part. Cygwin only gives you binaries for some  
programs. MySQL is not one of them. Usually, this isn’t a problem, so  
I went to the MySQL web site, grabbed the current 5.0 Windows binary  
and installed. (I actually had an older version, which I had to remove  
first.) This wasn’t a big deal. I even got the mysql bin directory in  
the $PATH variable in bash,

So here’s where things get bizzare. I build a table called stories in  
the MySQL tutorial, just like in the book, and it works just fine.  
Then I go to my Rails application and run scripts/console. Following  
the directions in the book. I enter the following code:

class Story \< ActiveRecord::Base; end  
==\> nil  
story = Story.new

This makes perfect sense to me, however, instead of getting a pleasant  
response from the second line, I get about twenty lines of exceptions.  
I won’t bother with the whole thing, but is starts off:

Errno::EBADF: Bad file descriptor - /tmp/mysql.sock  
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/  
active\_record/v  
endor/mysql.rb:107:in `initialize' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/v endor/mysql.rb:107:in`new’  
from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/  
active\_record/v  
endor/mysql.rb:107:in `real_connect' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/c onnection_adapters/mysql_adapter.rb:389:in`connect’  
…

Of course, what’s happening is that because Ruby emulates a Linux  
environment, it’s looking for the mysql.sock file in the most logical  
Linux location, but because my MySQL install is vanilla Windows, its  
not there, and there may not even be such a thing as a mysql.sock  
file. As far as I can tell, this leaves me with two unpalatable  
options.

1. I uninstall the MySQL service, download the source, and spend hours  
of my life trying to compile it from source under Cygwin.

2. I uninstall Ruby from cygwin, figure out where it placed gem,  
rails, and all the other support files it installed so strange things  
don’t happen in the future, and then install a vanilla Ruby / Rails  
installation like everyone else.

Both of these options seem like a lot of wasted effort. Is there a  
simple third solution that I am overlooking?

---

<div class="post-metadata">

**Author:** ![dcloutman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dcloutman](https://www.ruby-forum.com/u/dcloutman)\
**Post date:** [August 20, 2007, 9:14am UTC](https://www.ruby-forum.com/t/cygwin-ror-windows-mysql-binary-nil/112485/2 "2007-08-20T09:14:05Z")

</div>

dcloutman wrote:

> Of course, what’s happening is that because Ruby emulates a Linux  
> environment, it’s looking for the mysql.sock file in the most logical  
> Linux location, but because my MySQL install is vanilla Windows, its  
> not there, and there may not even be such a thing as a mysql.sock  
> file. As far as I can tell, this leaves me with two unpalatable  
> options.
> 
> 1. I uninstall the MySQL service, download the source, and spend hours  
> of my life trying to compile it from source under Cygwin.
> 
> 2. I uninstall Ruby from cygwin, figure out where it placed gem,  
> rails, and all the other support files it installed so strange things  
> don’t happen in the future, and then install a vanilla Ruby / Rails  
> installation like everyone else.
> 
> Both of these options seem like a lot of wasted effort. Is there a  
> simple third solution that I am overlooking?

You could connect over TCP/IP on localhost.

–  
Roderick van Domburg

> **[De domeinnaam Nedforce.nl is te koop.](http://www.nedforce.nl)**
>
> Deze mooie domeinnaam kan al over een paar minuten van jou zijn. Betalen gaat eenvoudig en vertrouwd via iDEAL. Direct na de betaling ontvang je de verhuiscode per e-mail en kun je aan de slag.

---

<div class="post-metadata">

**Author:** ![dcloutman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dcloutman](https://www.ruby-forum.com/u/dcloutman)\
**Post date:** [August 21, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/cygwin-ror-windows-mysql-binary-nil/112485/3 "2007-08-21T16:17:40Z")

</div>

Much simpler explanation: Rails is using /config/database.yml to find  
out how to connect to your database and you’ve got it set up in a way  
that tells it to use a tcp connection. Change /config/database.yml,  
dropping the definitions for host and socket for each DB environment  
you’re running from your win box.

AndyV

---

<div class="post-metadata">

**Author:** ![dcloutman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dcloutman](https://www.ruby-forum.com/u/dcloutman)\
**Post date:** [August 31, 2007, 7:53am UTC](https://www.ruby-forum.com/t/cygwin-ror-windows-mysql-binary-nil/112485/4 "2007-08-31T07:53:32Z")

</div>

It turns out the solution is simple. I just needed to set my host to  
127.0.0.1 instead of localhost and it worked like a charm.

On Aug 20, 12:14 am, Roderick van Domburg \<rails-mailing-l…@andreas-
