MySQL not Connected ...... *pull hair*

I’m trying to run " rake db:migrate " and im getting an error back:


C:\wamp\www\demoproject>rake db:migrate
(in C:/wamp/www/demoproject)
rake aborted!
Mysql::Error: query: not connected: CREATE TABLE schema_migrations
(version
varchar(255) NOT NULL) ENGINE=InnoDB

(See full trace by running task with --trace)


Something is definitely wrong because when I try to run "
script/dbconsole " i get an error also


C:\wamp\www\demoproject>ruby script/dbconsole
Couldn’t find database client: mysql, mysql5. Check your $PATH and try
again.


I have been fighting to get RoR installed for almost 2 weeks and my
patience and time is running low. This is as bad as when I first
installed apache, mysql and php on my system 7 years ago. I would gladly
pay for an installer that just made everything work!

Following info would help to know on giving you an idea of what to try
next:

What OS are you on?

How did you install Mysql?

Is Mysql service running?

Copy your database.yml

I’m running on Vista 32bit (VMware Fusion).

I installed MySQL with WAMP.

Yes the mysql service is running.

database.yml

development:
adapter: mysql
database: music_library_development
pool: 5
timeout: 5000
host: localhost

test:
adapter: mysql
database: music_library_test
pool: 5
timeout: 5000
host: localhost

production:
adapter: mysql
database: music_library_production
pool: 5
timeout: 5000
host: localhost

On Jul 2, 2010, at 12:14 PM, DK wrote:

(potentially) correct database.yml

Yes the mysql service is running.
host: localhost
In case the “hints” are too subtle, I suspect you took the example and
fixed sqlite3 => mysql and set your database name. Since SQLite
doesn’t need username/password, you didn’t have those in the example.
Put them in and you’re probably going to be all set.

-Rob

Rob B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/

Hi -
Here are some ideas - at least will be a start at isolating the problem.
I
am on a Mac so things might not be exact.

  1. Here is an example of working database.yml which is working with
    mysql.
    You may want to track down the differences and if they are meaningful.

Also, if you have not done, create a test rails app in cmd prompt using:
rails testapp -d mysql. This should autogenerate a (potentially) correct
database.yml

development:
adapter: mysql
encoding: utf8
reconnect: false
database: xxx_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock

  1. See if you can log in and access mysql. On a mac I do something in
    the
    terminal like: mysql -u [user name] -p [password]. Check out this
    article
    http://dev.mysql.com/doc/refman/5.0/en/windows-start-command-line.html.
    Once
    you get in see if you can create a db.

Rob B. wrote:

In case the “hints” are too subtle, I suspect you took the example and
fixed sqlite3 => mysql and set your database name. Since SQLite
doesn’t need username/password, you didn’t have those in the example.
Put them in and you’re probably going to be all set.

I’m not using SQLite, I have MySQL installed. I’m not getting permission
or login errors so I don’t see how that is relavant with an error like
this

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

I’m able to log in to MySQL and CRUD databases easily with PHPMyAdmin.
WAMP on Windows makes sure of this.

I tried your command for creating a test rails app in cmd and created a
new database. I still get the same error.

Like I mentioned in my original post, when I run ruby script/dbconsole
it gives me an error that it cannot find mysql client. So I think the
problem is beyond my database.yml config.

On Jul 2, 2010, at 12:46 PM, Dave Digital wrote:

this

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

Well, I’m taking “not connected” to indicate something that’s not too
different from a login error.

database.yml

development:
adapter: mysql
database: music_library_development
pool: 5
timeout: 5000
host: localhost

In your database.yml, there are no login credentials. Assuming that
you can get connected (logged in) to your mysql with absolutely no
user or password, maybe this is right, but I doubt it.

If your root user doesn’t have a password, try this:

development:
adapter: mysql
database: music_library_development
username: root
password:
pool: 5
timeout: 5000
host: localhost

(Note that there should be two spaces on the indented lines.)

If you have some other username/password, use those. In any case, you
should be able to connect with:
mysql -u root
mysql -u root -p

then type the root user’s password
mysql -u yourusername -p
then type yourpassword

How does that work for you?

-Rob

Rob B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/

development:
adapter: mysql
database: music_library_development
username: root
password:
pool: 5
timeout: 5000
host: localhost

(Note that there should be two spaces on the indented lines.)

If you have some other username/password, use those. In any case, you
should be able to connect with:
mysql -u root
mysql -u root -p

then type the root user’s password
mysql -u yourusername -p
then type yourpassword

How does that work for you?

-Rob

Rob B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/

I set my database.yml to this

development:
adapter: mysql
encoding: utf8
reconnect: false
database: testapp_development
pool: 5
username: root
password:
host: localhost

And still no luck. There is a larger issue here and not something as
simple as passwords. I’ve been fighting this for weeks. My love of rails
is turning to hate.

Dave Digital wrote:
[…]

And still no luck. There is a larger issue here and not something as
simple as passwords. I’ve been fighting this for weeks. My love of rails
is turning to hate.

This is probably not a Rails issue as such, so don’t start hating Rails
just yet.

More stuff to try:

  • Do you have the mysql gem installed? (It looks like you do, but…)
  • What version of MySQL are you running? (Some people have reported
    problems with 5.1; you may want to switch to 5.0.)

If it were my development setup, though, I’d avoid both MySQL and
Windows entirely. I don’t use Windows, but my understanding is that
besides its being a pretty bad OS in general, a lot of Rails tools run
less smoothly on it than on *nix (you can use a *nix VM, though).
Likewise, MySQL is a pretty bad DB in comparison to systems like
PostgreSQL.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

And to chime in… I have same experience that Windows is a suboptimal
environment, if not only from the fact that it 90% of the advice for
Rails
online is referring to *nix (including mac). I would also recommend
getting
up a simple Ubuntu vm. I tried configuring a Windows Server 2008
recently
for rails production env and it was 3 days of complete hell. I had the
whole
thing done on Ubuntu server in about 1/2 day. Not that I had the same
issue
as you with the db.

Either that or just install InstantRails for Windows and get
productive…
you can always learn to do the install later.

As you are running an uncommon environment I would suspect your socket is not where you expect it.  Try adding the line:
socket:  /tmp/mysqld.sock
or
socket:   /tmp/msql.sock
to your database.yml.  One of those might work.

Norm



You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.

To post to this group, send email to
[email protected]

To unsubscribe from this group, send email to
[email protected]

For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

I’m not sure if this is relevant but here goes.

You said you are running Vista 32bit (VMware Fusion) - what is running
in
VMWare fusion? Vista or something like VirtualRails?

I have something similar at home - run Ubuntu as my main OS, but have a
full
webserver VirtualBox to reduce the number of unneeded processes running
(only fire up the webserver vm when actually needed). My host OS does
not
have rails, MySQL client/server or gem installed at all.

The Rails source is in the VM, linked to a directory on my main os by
sshfs.
If I need to run any ruby, rails or MySQL command, it has to be run from
the
web vm cli, NOT the hosts.

For example, running “script/dbconsole” in a host cli box I get all
sorts of
horrible error messages, but it works as intended when run from a cli
from
the VM.

What I think I’m saying is - if your rails dev environment is in a VM,
use
the resources of the VM to run Rails/MySQL tasks, not the hosts.

HTH

On 2 July 2010 21:37, Hassan S. [email protected]
wrote:

ripple:~$ mysqladmin variables | grep socket
| socket | /tmp/mysql.sock

You’ll both have to chant differently than that to get the Windows
deity to hear… given that’s the OP’s OS :wink:

On Fri, Jul 2, 2010 at 1:29 PM, Norm S. [email protected]
wrote:

As you are running an uncommon environment I would suspect your socket is
not where you expect it. Try adding the line:
socket: /tmp/mysqld.sock
or
socket: /tmp/msql.sock
to your database.yml. One of those might work.

Sigh. Chanting over chicken bones might work, too. How about,
instead, use the tools at hand to find what you need to know :slight_smile:

ripple:~$ mysqladmin variables | grep socket
| socket | /tmp/mysql.sock
|
ripple:~$


Hassan S. ------------------------ [email protected]
twitter: @hassan

On Fri, Jul 2, 2010 at 1:40 PM, Michael P. [email protected]
wrote:

ripple:~$ mysqladmin variables | grep socket
| socket | /tmp/mysql.sock

You’ll both have to chant differently than that to get the Windows
deity to hear… given that’s the OP’s OS :wink:

Ah, point taken, but hopefully mysqladmin works on Windows, too,
so you at least get easy access to those variables. Hopefully. Just
realized I seriously have no idea :slight_smile:


Hassan S. ------------------------ [email protected]
twitter: @hassan

Hopefully your answer is in this thread.
http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407

one quick q:
did u install mysql after installing ror ?

-thanks

Dave Digital wrote:

I’m able to log in to MySQL and CRUD databases easily with PHPMyAdmin.
WAMP on Windows makes sure of this.

I tried your command for creating a test rails app in cmd and created a
new database. I still get the same error.

Like I mentioned in my original post, when I run ruby script/dbconsole
it gives me an error that it cannot find mysql client. So I think the
problem is beyond my database.yml config.

Update to the post:
Since the error says “cannot find mysql client”, follow these…

  • download older MySQL client library, for example one from
    InstantRails: http://instantrails.rubyforge.org/svn/t … bmySQL.dll

  • copy the downloaded file to C:\Ruby\bin (or wherever you installed
    Ruby)

  • restart MySQL server

src: >
http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407

RailsFan R. wrote:

Hopefully your answer is in this thread.
http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407

one quick q:
did u install mysql after installing ror ?

-thanks

Dave Digital wrote:

I’m able to log in to MySQL and CRUD databases easily with PHPMyAdmin.
WAMP on Windows makes sure of this.

I tried your command for creating a test rails app in cmd and created a
new database. I still get the same error.

Like I mentioned in my original post, when I run ruby script/dbconsole
it gives me an error that it cannot find mysql client. So I think the
problem is beyond my database.yml config.

Sure get a Mac :wink:

No but seriously first there’s no reason why your app should be in the
www folder the only thing you want to expose to the world is he public
folder and you can do that by simlinking I don’t know what the
equivalent is on windows well I don’t know why anyone does web dev on
a non unix Linux environnment but I’ve seen weirder things… Also
you’ll need phusion passenger to get your ruby working with apache. If
you want a prepackaged server stack look into http://bitnami.org/ I
got them working on my win 7 box of failure (does my bias come
through ?) but before you do all that you should know that you don’t
need a separate server to develop your ruby rails app. Rails come with
it’s own server you can use while developing…

Cheers

Victor

Also as someone mentioned already. You want to keep an eye on the
mysqlserver socket… But if your just working on local to develop
screw mysql use sqlite3 and just use mysql on production… Which
hopefully is not an iis server…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs