Newbie question : error when trying to use mysql instead of sqlite

hi,

I am trying to use mysql instead of sqlite in RoR.(using Aptana Studio) 1) I added this line to the gem file gem 'mysql2' 2)ran bundle install 3)made changes to the database.yml file default: &default   adapter: mysql2   pool: 5   timeout: 5000   encoding: utf8   username: root   password: ******   host: 127.0.0.1   port: 3306

development:   <<: *default   database: rails_development (has test and production also)

5) I type rails dbconsole / rails db on the terminal and get this error: Couldn't find database client: mysql, mysql5, mysql.exe, mysql5.exe. Check your $PATH and try again.

6) I added C:\Program Files\MySQL\MySQL Server 5.5\bin to the path

The error is still there. What to do ?

To be able to use “rails dbconsole”, mysql.exe needs to be in the PATH.

Doing “rails dbconsole” is exactly the same as doing to MySQL Console Client shortcut that should have been installed in your system.

If not, you can add the location of your MySQL installation (where mysql.exe lives) to the PATH doing the following on a console:

SET PATH=%PATH%;C:\path\to\mysql

However, to avoid issues with spaces and such, I recommend you use the MySQL Console Client shortcut.

Or Use Ubuntu In Short.

Hi Rajeev,

thanks for the reply.

However I have already added the path (where mysql.exe lives) to PATH. You can see point (6) in my first post.

The error is still there.

Also, when I try to migrate, there is no output on the console. I was successfully able to use migrate command when using sqlite.

Any help will be appreciated.

http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

look at this, it might help.

Thanks

Did you install MySQL? Pardon if this is really basic, but your post doesn’t actually say you installed MySQL, so it seems prudent to ask.

(The Ruby gem is just the adapter to allow Rails to access MySQL, it doesn’t install MySQL for you.)

Hi Scott,

I am new to Ruby on Rails. But I have been coding with java for long now.

I had MySql installed on my system from before. So I just did the above steps. It should have worked.

What am I doing wrong ?

Don’t know, because I don’t work with Windows—just wanted to make sure you had MySQL.

One other thing, the log snippet you posted looked kind of like the server was running and client was failing to connect—but I’m not sure. Have you checked in Task Manager whether there is any pg process running?

1. Make sure you copy libmysql.dll into your ruby\bin directory. 2. From a command prompt, type irb and enter. 3. Type require 'mysql2' and hit enter. => Should return true

If it is not true ask the following:

Are you using a 32-bit version of Ruby and a 32-bit version of MySQL? Or, a 64-bit?

Hi,

I had similar issue. It turned out there were double quotes around MySQL path in the %PATH% variable. While windows could recognize the path, rails couldn’t. Removing the quotes enables rials (and windows) to see the path.

Error case: PATH = …;“C:\Program Files\MySQL\MySQL Server 5.5\bin”;…

Good case: PATH = …;C:\Program Files\MySQL\MySQL Server 5.5\bin;…