Topic: Windows 7, RoR, and Mysql???

I'm a .net dev who wants to try out ruby on rails, but after 4 hours of trying to get it to work on Windows 7 with MySQL, I'm about to pull my hair out.   

The default "Welcom aboard" page comes up, but the picture doesn't and in the console I get:
"Mysql2::Error (Can't connect to MySQL server on 'localhost' (10061)):"

I've seen about a thousand guides/tutorials/posts/etc.. on why this happens and how to fix it, but nothing has worked.

Here is the process I've come up with:

    - Install Ruby
        - http://rubyinstaller.org/downloads/
    - Make sure gem is up to date
        - gem update --system
    - Install Rails
        - gem install rails
    - Install MySQL
        - http://www.mysql.com/downloads/mysql/
    - Install mysql gem
        - gem install mysql2
    - Install Ruby on windows dev kit
        - https://github.com/oneclick/rubyinstall … opment-Kit
        - Generate devkit config file
            - C:\RubyDevKit> ruby dk.rb init
        - Run dev kit install
            - C:\RubyDevKit> ruby dk.rb install
        - Test Installation
            Confirm your Ruby environment is correctly using the DevKit by running gem install rdiscount --platform=ruby. RDiscount should install correctly and you should see Temporarily enhancing PATH to include DevKit... in the screen messages. Next run ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello RubyInstaller**').to_html" to confirm that the rdiscount gem is working.
    - Fix MySQL connector DLL
        - http://www.mysql.com/downloads/connector/c/
            - download mysql-connector-c-noinstall-6.0.2 zip (32 bit version)
            - copy libmysql.dll from lib directory inside zip and paste it into ruby bin install location "C:\Ruby193\bin"
                        - compile mysql2 with my version of mysql connector
                             - gem install mysql2 --platform=ruby -- --with-mysql-dir=C:/RailsInstaller/mysql

Versions I'm using:
Win 7 64bit
Ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
Rails 3.2.6
MySql Ver 14.14 Distrib 5.5.25, for Win64 (x86)
mysql-connector-c-noinstall-6.0.2-win32
mysql2 (0.3.11 ruby x86-mingw32)
database.yml:
development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: simple_cms_development
  pool: 5
  username: root
  password:
  host: localhost

I can pull up a mysql prompt, login and see the databases.  So, I think MySql is working, there is just some connection issue where Rails can't talk to it.  Any ideas would be greatly appreciated.
Thanks

Last edited by TimB (2012-06-29 16:04:06)

Re: Windows 7, RoR, and Mysql???

Same Here. I tried  twice on two different computers. Always faced the same problem. I had some previous sql problem by running x64 db connector but reverted to 32 bits. Now I'm stuck on the same error as you. If I don't get this fixed tomorrow, I'll just drop the thing altogether and go to another language platform where at least I know I can solve the problems I run into.

Re: Windows 7, RoR, and Mysql???

First thing  - you had to install DevKit before installing mysql2 gem. In your workflow it comes after. May be that is the reason. I installled a lot of times RoR environment on XP, 7 (32 or 64 bites) without any problems.
Second point - I have never had to install mysql2 gem as you did:

- gem install mysql2 --platform=ruby -- --with-mysql-dir=C:/RailsInstaller/mysql

just Ruby -> DevKit-> mysql2 gem -> mysql dll copied in Ruby bin directory. And it always worked like a charm.
If you still have problems with that, post the stack trace errors at mysql2 GIT issues https://github.com/brianmario/mysql2/issues or at Ruby Installer google groups: https://groups.google.com/forum/?fromgr … installer. The guys from there are at ease to help you:)

Last edited by Javix (2012-07-22 16:18:40)

Re: Windows 7, RoR, and Mysql???

I'll try that first thing in the morning when I get to work. I'll unstall everything except mysql server and connector
then I'll follow the chain:

Ruby -> DevKit-> mysql2 gem -> mysql dll copied in Ruby bin directory

Now, just to be sure, is installing the environnment through railsinstaller.exe compatible with the chain order you mention or you don't recommend doing that?

Last edited by muichkine (2012-07-22 16:35:32)

Re: Windows 7, RoR, and Mysql???

I would guess that you are not using the correct address for the socket to connect to mysql.  Take a look at the mysql.conf to see what it is using and then specify that file location in the database.yml

Re: Windows 7, RoR, and Mysql???

OK, I reinstalled everything following the given order. I did start a rails sqllite projet which seemed to run fine. I created a mysql projet (rails new project -d mysql) and....same error once again and again.

I have no clue at all where rails get the idea of connecting to port 10061 for mysql. My root project's database.yml looks like this:

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: simple_cms_development
  pool: 5
  username: root
  password: *********
  host: localhost
  port: 3306
  socket: /tmp/mysql.sock

The simple_cms_development db is existing. The password is my real root password which works when connecting to the db through mysql workbench. the socket is the one stated in the mysql_config.pl file.

Now, what else can one do?

Re: Windows 7, RoR, and Mysql???

OK, go the answer:

Adding (uncommenting)
127.0.0.1 localhost
C:\Windows\System32\drivers\etc\hosts
solved this.

Taken from:
https://github.com/brianmario/mysql2/issues/157

Re: Windows 7, RoR, and Mysql???

Personally, I've never used rails installer. What for? You already have everything you need: Ruby windows installer + DevKit. The rest is just to download mysql installer, install needed gems from the console, copy-paste mysql DLL where needed; That's all. Why to apply for any additional 3-party vendor,? - to have some unexplainable config errors like that?

Last edited by Javix (2012-07-23 11:17:32)

Re: Windows 7, RoR, and Mysql???

Wow... I had seriously given up on this.  I spent a week messing with it, then moved on to ASP.NET MVC.  Maybe I'll give this another shot, Thanks for the ideas.

Are there any other forums for Rails, or is this the most active one?

Re: Windows 7, RoR, and Mysql???

Cheap dolce gabbana shoes are a popular option to match with any of the summer,wholesale Gucci clothingavailable. These kind of shoes are generally paired with short crew socks and are sometimes worn by themselves. discount louis vuitton shoes can either have laces, zippers or just elastic so they can be easily slipped on. cheap gucci wallets They are the perfect shoes to wear with your cheap Hollister t shirts when you are on the go. Cheap Gucci Belts are recommended for all Wholesale Cheap Gucci Shoes casual Cheap Louis Vuitton Shoes styles. They are easy to wash and dry quickly making them the ideal shoe for any outdoor activity. Don’t start the summer without buying a pair of canvas shoes to wear with your Cheap Nike Air Jordan Shoes.This summer you may be geared up for some sunny days on the beach, or barbequing in the backyard but do you have your wardrobe and Cheap Burberry Clothing style all figured out? It may cheap dolce gabbana t shirtst be a good idea to get your cheap gucci clothing wardrobe in order so you look your best all season long. Below are some of the tips to help you decide what cheap louis vuitton shoesreplica gucci clothing will suit your look and the cheap armani jeans in style to match. By knowing what discount coogi jeans can be paired with the different types of louis vuitton clothing online you will be able to organize your shopping trips accordingly.Another popular shoe to wear with summer cheap gucci t-shirts is the tennis shoe. cheap ysl t-shirts have flat soles and are usually white in color. Wearing white during the summer helps reflect the suns rays away from the body keeping you cool. Cheap lv t-shirts especially look nice when worn with khakis and board shorts. cheap Armani t-shirts can be worn with Cheap Prada Shoes from any season but it is best to avoid wearing them when it is damp outside. Cheap DG Shoes look good when they are free from mud stains and scuff marks. Cheap LV Shoes can be worn for any athletic activity that allows a flat sole. Tennis, badminton and skateboarding are just some of the physical activities that these cheap ysl t-shirts are ideal for. TheRetail air jordan shoes,was developed simply byair jordan shoes on sale,for the particular NBA experiencedcheap nike jordan shoes,however later began enhancing each and every United states teen's feet. As these Air Jordan 3.5 shoes ...

Re: Windows 7, RoR, and Mysql???

and that's another reason I want a different forum...  This one is REALLY bad about spam.