15

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

1
  • From the error I would say that the charset of your database does not match what you are trying to do: charset: utf8 collation: utf8_unicode_ci Not sure if there is a way to set the charset of a query in rails? Commented Sep 16, 2009 at 11:26

5 Answers 5

6

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

Sign up to request clarification or add additional context in comments.

3 Comments

I used 127.0.0.1 instead of localhost...it seems to make difference.
maybe this makes it more clear: stackoverflow.com/questions/7382602/…
Wow, for me it was the opposite: 127.0.0.1 didn't work but localhost did
4

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.

Comments

0

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

Comments

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

works for me. Thank you!

Comments

0

You will check out your usrname and password whether its correct or not. Also you will check out whether your mysql server is working correctly. and also some time found the problem of socket path most of the time its is inside /tmp directory but sometimes it may not be. so try with with the default path.

Hopefully if you will try this it will work for you.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.