Beginner's question: Rails 3 and MySQL on Windows

31 views
Skip to first unread message

Barney

unread,
Jun 29, 2011, 5:17:47 PM6/29/11
to Ruby on Rails: Talk
Hello,
I've failed to get Rails 3 to connect to MySQL and have read that
the current MySQL ( which is MySQL2) doesn't work with Rails 3. It
isn't clear to me, from looking at the primarily *nix instructions on
the net, how to do this in Windows: settings in database.yml, gems to
install, where to get a MySQL database that works and where to put it,
etc. What are the proper steps?
Thanks,
Barney

Chirag Singhal

unread,
Jun 30, 2011, 3:20:11 AM6/30/11
to rubyonra...@googlegroups.com
Easiest way to get started with Rails on Windows is to use RailsInstaller - http://railsinstaller.org/

MySQL 5.1 has issues with Rails on windows, so better use MySQL 5.0, while installing either choose the option where mysql exe is added to path or copy libmysql.dll after installation to ruby's bin folder.

If this doesn't work, then post the exact error you encounter and we will take it from there.

John Ivanoff

unread,
Jun 30, 2011, 8:58:05 AM6/30/11
to Ruby on Rails: Talk
I have a post http://bit.ly/lNxcB1 where I did a clean install for
rails 3 any MySQL. I am also using MySQL 5.1 on Win XP
It is a pain to get it going on windows but once you do it run OK.
Also on my blog I've posted a few gotcha's I've had with windows and
some gems.

Hope it helps.

John

On Jun 30, 2:20 am, Chirag Singhal <chirag.sing...@gmail.com> wrote:
> Easiest way to get started with Rails on Windows is to use RailsInstaller -http://railsinstaller.org/

John Ivanoff

unread,
Jun 30, 2011, 9:20:58 AM6/30/11
to Ruby on Rails: Talk
example yml setting

development:
adapter: mysql
encoding: utf8
reconnect: false
database: name_of_database
pool: 5
username: agoodone
password: secret
socket: /tmp/mysql.sock


I've always used mysql Gem
> gem install mysql

John

On Jun 30, 7:58 am, John Ivanoff <john.ivan...@gmail.com> wrote:
> I have a posthttp://bit.ly/lNxcB1where I did a clean install for

Barney

unread,
Jun 30, 2011, 1:54:23 PM6/30/11
to Ruby on Rails: Talk
Hi Guys,
Thanks for the replies, but I'm still stuck with "rake
db:migrate" failing. I get a popup window that says that LIBMYSQL.DLL
can't be found and the command line says that c:/ruby192/lib/ruby/gems/
ruby 1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so can't be
found (the statement has the Windows slashes backward but I don't know
where that request is coming from in the code and I suspect that it
doesn't matter, anyway). Using the parameter "--trace" shows a lot of
lines but none of them are marked as creating the error. I've
installed MySQL 5.5.13 today from the MySQL.com community site but I
have no evidence that that is being used.
Any suggestions on what is stopping this progress would really be
appreciated!
Barney

On Jun 30, 9:20 am, John Ivanoff <john.ivan...@gmail.com> wrote:
> example yml setting
>
> development:
>   adapter: mysql
>   encoding: utf8
>   reconnect: false
>   database: name_of_database
>   pool: 5
>   username: agoodone
>   password: secret
>   socket: /tmp/mysql.sock
>
> I've always used mysql Gem
>
> > gem install mysql
>
> John
>
> On Jun 30, 7:58 am, John Ivanoff <john.ivan...@gmail.com> wrote:
>
> > I have a posthttp://bit.ly/lNxcB1whereI did a clean install for

Barney

unread,
Jun 30, 2011, 5:43:51 PM6/30/11
to Ruby on Rails: Talk
Well, to use a former co-workers phrase, "I've been crawling over
broken glass", trying everything and seemed to have found something
that worked: 1) I downloaded and installed MySQL community edition
5.5.13, even though it isn't on anyone's recommended list and 2)
installed a gem for mysql-2.8.1-x86-mingw32 which I saw recommended
somewhere, then 3) modified John's yml file from above to be:

development:
adapter: mysql
encoding: Latin1
reconnect: false
database: mysql
pool: 5
timeout: 5000
username: a
password: a

and the line: rake db:migrate finally worked and made a table with
the data I had in that file. Also, I could add a couple of records
via the screen from http://localhost:3000/people
so I think I can make progress from here. Thanks to John and Chirag
for taking the time to point me in some good directions!
Barney

Barney

unread,
Jun 30, 2011, 6:09:22 PM6/30/11
to Ruby on Rails: Talk
Sorry, left out a step from the above:

Get a dll:
http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll
and put it in c:\ruby192\bin with other dlls

That's before, of course, running: rake db:migrate in the ruby
command line shell

 Barney

Luis Lavena

unread,
Jul 1, 2011, 11:11:38 AM7/1/11
to Ruby on Rails: Talk
On Jun 30, 2:54 pm, Barney <bsper...@gmail.com> wrote:
> Hi Guys,
>      Thanks for the replies, but I'm still stuck with "rake
> db:migrate" failing.  I get a popup window that says that LIBMYSQL.DLL
> can't be found and the command line says that c:/ruby192/lib/ruby/gems/
> ruby 1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so  can't be
> found (the statement has the Windows slashes backward but I don't know
> where that request is coming from in the code and I suspect that it
> doesn't matter, anyway).  Using the parameter "--trace" shows a lot of
> lines but none of them are marked as creating the error.  I've
> installed MySQL 5.5.13 today from the MySQL.com community site but I
> have no evidence that that is being used.

You need libmysql.dll from MySQL 5.0.x, which was used to build mysql
gem binaries.

Either you download that or you can force compilation of MySQL gem
following these instructions (see MySQL/C Connector)

https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting#gems_mix_bits
http://stackoverflow.com/questions/5367563/unable-to-install-mysql2-gem-on-windows-7/5368767#5368767

--
Luis Lavena
Reply all
Reply to author
Forward
0 new messages