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

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

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

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.

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.

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

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 Biedenharn

Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/

rab@GaslightSoftware.com http://GaslightSoftware.com/

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.

Rob Biedenharn 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

Well, I'm taking "not connected" to indicate something that's not too different from a login error.

database.yml

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,

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.

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

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

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:~$

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:

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:

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 Radha wrote:

looks like the link didn't get thru..
here it is
http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll

RailsFan Radha wrote:

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