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

76 views
Skip to first unread message

Manvi Sharma

unread,
May 1, 2015, 6:27:16 AM5/1/15
to rubyonra...@googlegroups.com
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 ?

--
Posted via http://www.ruby-forum.com/.

rajeevsharma86

unread,
May 1, 2015, 6:30:08 AM5/1/15
to Ruby on Rails: Talk
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.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/cb2f5d449387498f87a2a169736ea1e2%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.



--

Manvi Sharma

unread,
May 1, 2015, 6:54:19 AM5/1/15
to rubyonra...@googlegroups.com
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.

rajeevsharma86

unread,
May 1, 2015, 7:20:10 AM5/1/15
to Ruby on Rails: Talk

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Scott Ribe

unread,
May 1, 2015, 9:06:06 AM5/1/15
to rubyonra...@googlegroups.com, Manvi Sharma
On May 1, 2015, at 4:53 AM, Manvi Sharma <li...@ruby-forum.com> wrote:
>
> However I have already added the path (where mysql.exe lives) to PATH.
> You can see point (6) in my first post.

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.)

--
Scott Ribe
scott...@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice





Manvi Sharma

unread,
May 1, 2015, 9:21:06 AM5/1/15
to rubyonra...@googlegroups.com
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 ?

Scott Ribe

unread,
May 1, 2015, 10:06:50 AM5/1/15
to rubyonra...@googlegroups.com, Manvi Sharma
On May 1, 2015, at 7:20 AM, Manvi Sharma <li...@ruby-forum.com> wrote:
>
> 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?

Joel Dezenzio

unread,
May 3, 2015, 6:44:53 PM5/3/15
to rubyonra...@googlegroups.com
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?

Marat Zilberman

unread,
Jun 13, 2015, 4:11:01 PM6/13/15
to rubyonra...@googlegroups.com
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;....
Reply all
Reply to author
Forward
0 new messages