Mysql::Error: query: not connected

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?

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

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

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

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

what version of mysql did you install ?

Fred

MySQL 5.1.37

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

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.

Peter

Best,

MySQL 5.1.37

I think most people are still running 5.0.x

Fred

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.