views:

2484

answers:

4

Hello,

I'm using Ruby1.9 and Rails 2.3.4 and I have mysql-ruby (2.8.1) gem installed.

when I try rake db:create I get the following

Couldn't create database for {"adapter"=>"mysql", "database"=>"war_development", "username"=>"root", "password"=>nil, "host"=>"localhost"}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)

My database.yml has the following for development

development:
  adapter: mysql
  database: war_development
  username: root
  password: 
  host: localhost

Any ideas what's going wrong?

Thanks,

Tam

A: 

Are you allowed to use the root user without password? Is the mysqlserver listening on 127.0.0.1 or localhost?

Lichtamberg
Did that help you?
Lichtamberg
I used 127.0.0.1 instead of localhost...it seems to make difference.
Tam
A: 

I'm having this same problem and changing the host to 127.0.0.1. This problem started when I upgraded to snow leopard. I've followed this http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard. But I still get the same error Tam has posted above.

I've been messing with this issue for over a week now, kinda strange I can't find a solution anywhere.

any suggestions?

Thanks, Dan

Dan
+1  A: 

Hi. Strange to see some behaviour changed, and I don't know if it is specific to snow leopard. I use tiger and got the same error. I added

  host: 127.0.0.1

to the following (ofcourse with a correct mysql root/pw)

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

And it worked (on tiger/gem mysql-2.8.1/mysql Ver 14.14 Distrib 5.1.30). Hope it helps.

Wouter
A: 

I followed the steps in another SO thread. However, the command for my installation is different from that of there, as I am not upgrading an existing db but installing a fresh one. So instead of advised one

$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

I typed the following

$ sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql/bin/mysql

PS: host: localhost remains as is, no need to change to 127.0.0.1

Comptrol