Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when trying to create database with Rails, rake db:create

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

like image 475
Tam Avatar asked Sep 16 '09 11:09

Tam


2 Answers

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

like image 146
BvuRVKyUVlViVIc7 Avatar answered Oct 09 '22 14:10

BvuRVKyUVlViVIc7


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.

like image 23
Wouter Avatar answered Oct 09 '22 13:10

Wouter