Mysql::Error: query: not connected

111 views
Skip to first unread message

Zovar

unread,
Nov 3, 2009, 5:02:50 PM11/3/09
to Ruby on Rails: Talk
Hi there!

I am PHP developer and trying to learn ROR. Currently I am building my
first Rails website (OS X Snow Leopard, TextMate) and decided to
switch from sqlite to mysql. After many-many hours of searching the
internet I managed to install mysql gem. Now I get this error when I
try to run rake migrations:

rake aborted!
Mysql::Error: query: not connected: CREATE TABLE `schema_migrations`
(`version` varchar(255) NOT NULL) ENGINE=InnoDB


I read somewhere that new latest Rails doesn't work with mysql
properly and I have to reinstall mysql etc etc.

I am seriously tired of this, it just doesn't make any sense. I can
set up Apache+PHP+MySQL environment literary in minutes, why Rails
+MySQL takes days?? Is there a safe stack of Ruby+Rails+MySQL that I
can just install and concentrate on web development?

Frederick Cheung

unread,
Nov 3, 2009, 5:10:32 PM11/3/09
to Ruby on Rails: Talk


On Nov 3, 10:02 pm, Zovar <peter.zavor...@gmail.com> wrote:
> Hi there!
>
> I am PHP developer and trying to learn ROR. Currently I am building my
> first Rails website (OS X Snow Leopard, TextMate) and decided to
> switch from sqlite to mysql. After many-many hours of searching the
> internet I managed to install mysql gem. Now I get this error when I
> try to run rake migrations:
>
> rake aborted!
> Mysql::Error: query: not connected: CREATE TABLE `schema_migrations`
> (`version` varchar(255) NOT NULL) ENGINE=InnoDB
>
> I read somewhere that new latest Rails doesn't work with mysql
> properly and I have to reinstall mysql etc etc.
>

What's in your database.yml ? If you cd to your app and run

ruby script/dbconsole

then rails will open up a mysql console using the connection
parameters from your database.yml file, if that doesn't work then
there's definitely something wrong with that configuration file.

> I am seriously tired of this, it just doesn't make any sense. I can
> set up Apache+PHP+MySQL environment literary in minutes, why Rails
> +MySQL takes days??

Because you're new to rails. I can set up rails and mysql pretty damn
quick but it would probably take me way longer to set up php & mysql
or some java based framework, but that's just to be expected given the
tools I know.

Fred

Dhruva Sagar

unread,
Nov 3, 2009, 5:17:44 PM11/3/09
to rubyonra...@googlegroups.com
I've recently faced the same problem.
What I understood from the pages I visited from google was that the rails 2.3.3 which I had installed on my windows xp machine didn't work properly with the mysql driver (libmysql.dll). I had to download a different version and add it in c:\ruby\bin I will be able to get more information in some 3 more hours when I will be in office where I experienced this error

Thanks & Regards,
Dhruva Sagar.


Jonathan Swift  - "May you live every day of your life."

Zovar

unread,
Nov 3, 2009, 7:56:08 PM11/3/09
to Ruby on Rails: Talk
Hi Fred, thanks for you reply.

My database.yml:

development:
adapter: mysql
encoding: utf8
database: dom
pool: 5
username: my_username
password: my_password
socket: /tmp/mysql.sock

(same settings both for test and production environments just for now)

if I run ruby script/dbconsole I get this error:

Couldn't find database client: mysql, mysql5. Check your $PATH and try
again.

Also if I run rake db:create it creates a database without any
problems, but any rake db:migrate raises an exception:

Mysql::Error: query: not connected: CREATE TABLE `schema_migrations`
(`version` varchar(255) NOT NULL) ENGINE=InnoDB


> Because you're new to rails. I can set up rails and mysql pretty damn
> quick but it would probably take me way longer to set up php & mysql
> or some java based framework, but that's just to be expected given the
> tools I know.

The thing is - it seems there is no definite tutorial for ROR+MySQL, I
followed one to install ROR, then another to get mysql, then another
to install mysql gem and now I am stuck, because it just doesn't work.
I am not a unix-master, I don't want to compile some obscure versions
of mysql, then move all the files around, compile gems, then remove
this, install that...

Peter

Zovar

unread,
Nov 3, 2009, 7:58:27 PM11/3/09
to Ruby on Rails: Talk
Hi Dhruva, thanks for your reply.

This is exactly what I am talking about. The problem is, that this
recommendation to copy mysql dll file won't work on OS X. That's why I
am stuck. I followed Rails tutorials to install mysql gem and now it
turns out that Rails doesn't work with it's own gem.

Peter

Frederick Cheung

unread,
Nov 4, 2009, 3:59:19 AM11/4/09
to Ruby on Rails: Talk
what version of mysql did you install ?

Fred

Marnen Laibow-Koser

unread,
Nov 4, 2009, 6:29:33 AM11/4/09
to rubyonra...@googlegroups.com
Zovar wrote:
[...]

> The thing is - it seems there is no definite tutorial for ROR+MySQL,

There are lots.

(But you shoul really be using PostgreSQL anyway -- it's a much better
DB.)

> I
> followed one to install ROR

That could be part of your problem. Did you follow Hivelogic's guide to
installing Rails? If so, you wasted your time. Mac OS developer tools
include perfectly usable versions of Ruby, RubyGems, and Rails; the
Hivelogic tutorials started at a time when this was not the case.
(Their mySQL installation guide seems pretty good, though.)

>, then another to get mysql, then another
> to install mysql gem and now I am stuck, because it just doesn't work.
> I am not a unix-master, I don't want to compile some obscure versions
> of mysql, then move all the files around, compile gems, then remove
> this, install that...

You should not have to. However, you will get better help if you don't
whine. :)

Also, it is possible to do development in many PHP frameworks without
really understanding the system you're working with. It is perhaps a
bit less possible in Rails. On balance, that's probably a good thing.

>
> Peter

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
--
Posted via http://www.ruby-forum.com/.

Zovar

unread,
Nov 4, 2009, 6:37:45 AM11/4/09
to Ruby on Rails: Talk
MySQL 5.1.37

On Nov 4, 8:59 am, Frederick Cheung <frederick.che...@gmail.com>
wrote:

Zovar

unread,
Nov 4, 2009, 7:09:39 AM11/4/09
to Ruby on Rails: Talk
> Also, it is possible to do development in many PHP frameworks without
> really understanding the system you're working with. It is perhaps a
> bit less possible in Rails. On balance, that's probably a good thing.

Is it possible to understand the system without even starting to use
it? The good thing is that anyone can enable Apache+PHP in OS X, then
download and install MySQL and they will just work. The bad thing
thing is that if you follow the official tutorial on how to install
ROR, then install MySQL and run gem install mysql - it won't work.
That's the real bad thing. It has nothing to do with PHP frameworks.


Peter

Marnen Laibow-Koser

unread,
Nov 4, 2009, 8:59:15 AM11/4/09
to rubyonra...@googlegroups.com
Zovar wrote:
>> Also, it is possible to do development in many PHP frameworks without
>> really understanding the system you're working with. It is perhaps a
>> bit less possible in Rails. On balance, that's probably a good thing.
>
> Is it possible to understand the system without even starting to use
> it?

By "system", I meant the OS, not the app framework.

> The good thing is that anyone can enable Apache+PHP in OS X, then
> download and install MySQL and they will just work. The bad thing
> thing is that if you follow the official tutorial on how to install
> ROR, then install MySQL and run gem install mysql - it won't work.
> That's the real bad thing.

The official site says that ROR is installed by default on Mac OS.
MySQL installs the same way regardless of whether you're using PHP or
Ruby. So that leaves the mysql gem, which does just work. Your case is
apparently not typical -- the "install mySQL, install mysql gem, go"
works for nearly everyone.

> It has nothing to do with PHP frameworks.

Nor with Rails. Sounds like your particular setup.

Frederick Cheung

unread,
Nov 4, 2009, 9:57:54 AM11/4/09
to Ruby on Rails: Talk


On Nov 4, 11:37 am, Zovar <peter.zavor...@gmail.com> wrote:
> MySQL 5.1.37
>
I think most people are still running 5.0.x

Fred

Marnen Laibow-Koser

unread,
Nov 4, 2009, 10:44:01 AM11/4/09
to rubyonra...@googlegroups.com
Frederick Cheung wrote:
> On Nov 4, 11:37�am, Zovar <peter.zavor...@gmail.com> wrote:
>> MySQL 5.1.37
>>
> I think most people are still running 5.0.x
>
> Fred

Really? I think I've used 5.1 both with PHP and Rails (although I no
longer have access to those boxes, so I can't verify that).

Rick

unread,
Nov 4, 2009, 11:18:01 AM11/4/09
to Ruby on Rails: Talk
Zovar - what do you have for versions? For example, here's what I've
got:

OS X => 10.5.8
PowerPC G4

mysql --version =>
mysql Ver 14.14 Distrib 5.1.39, for apple-darwin9.5.0 (powerpc)
using readline 5.1

ruby --version =>
ruby 1.8.7 (2009-06-08 patchlevel 173) [powerpc-darwin9.7.0]
ruby 1.9.1p243 (2009-07-16 revision 24175) [powerpc-darwin9.8.0]
ruby 1.9.2dev (2009-10-18 trunk 25393) [powerpc-darwin9.8.0]

rails --version =>
Rails 2.3.4
Rails 3.0.pre (with ruby 1.9.2dev only)

gem list mysql =>
mysql (2.8.1)

With this configuration all rails 2.3.4 activerecord tests on mysql db
pass. You'll notice that I'm running old hardware (ppc) and OS
(leopard sans snow). Don't loose heart - I expect we can get you up
and running.

On Nov 4, 10:44 am, Marnen Laibow-Koser <rails-mailing-l...@andreas-
Reply all
Reply to author
Forward
0 new messages