5
kratos-iii:railsproj zachinglis$ rake db:create
(in /Users/zachinglis/Sites/rails/railsproj)
Couldn't create database for {"adapter"=>"mysql", "host"=>"localhost", "username"=>"root", "password"=>nil, "database"=>"railsproj_development"}, charset: utf8, collation: utf8_general_ci (if you set the charset manually, make sure you have a matching collation)

I had no issues using Sequel Pro and even creating said database.

How do I resolve this? Having an empty password never gave me issues before. And I really doubt thats it.

Zach Inglis
  • 1,242
  • 1
  • 14
  • 28
  • 1
    What exactly do want to know? Please write a real question! – Christoph Schiessl Sep 01 '09 at 18:01
  • 2
    Your password being empty probably is the problem, but who knows with such a vague "question"? I would recommend restarting the question with a question mark somewhere so people know what the actual point in question is. – Godeke Sep 01 '09 at 18:23

7 Answers7

6

I was having the same problem than you, me and my friends were all going mad because of it, until we've found this link http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard

I've just followed the mysql installation steps and it worked great here :]

Michiel de Mare
  • 41,982
  • 29
  • 103
  • 134
bobsouza
  • 96
  • 5
3

I happened on same problem after installing new database server MySQL5.0 to 5.1. If you have installed new db-server, Your mysql gem library is not suitable for your database server. You may solve this by reinstall mysql gem lib.

 sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/your/mysql_config
kdoya
  • 46
  • 4
3

Re-install mysql-server and mysql-client using this command:

sudo apt-get install mysql-server mysql-client

and then some libraries you need to install to make MySQL available to ruby:

sudo apt-get install libmysql-ruby

This all solved my problem. Try it !!! :)

Nimesh Nikum
  • 1,809
  • 13
  • 17
1

I just encountered this as well on a fresh Snow Leopard install.

I had another project that created the databases without issue, but my primary project would give the errors you described. After poking around, the only difference was the former specified a socket, whereas the failing project (and yours too) uses a host.

That is to say, this database.yml causes the problem:

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

But this works:

development:
  adapter: mysql
  database: fanvsfan_development
  username: root
  password:
  socket: /tmp/mysql.sock

I'm unsure what the actual difference is, but this seems like a workaround.

1

Using RVM? Do this for Rails v 2.3

export ARCHFLAGS="-arch x86_64" ; gem install --no-rdoc --no-ri mysql -v 2.7 -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/local/mysql/bin/mysql_config
Coderama
  • 11,050
  • 12
  • 44
  • 58
0

This is a good reference. And I got if fixed through this http://www.ultrasaurus.com/sarahblog/2008/12/getting-started-with-rails-2-day-1/

Lakshmi
  • 1,759
  • 4
  • 18
  • 23
-1

Does the database already exist? Is MySQL setup and running? What changed? (OS Upgrade maybe)? Does a fresh rails app work? What about your other environments (test, production)?

Is there a back trace? you could post (use rake --trace db:create). Usually MySQL is returns a very explicit error message, rake is just eating it.

John F. Miller
  • 26,961
  • 10
  • 71
  • 121
  • The database exists, I can access MySQL. I created the db as a test & created a table. I started FRESH on Snow Leopard. All environments fail similarly. Backtrace: ** Invoke db:create (first_time) ** Invoke db:load_config (first_time) ** Invoke rails_env (first_time) ** Execute rails_env ** Execute db:load_config ** Execute db:create Couldn't create database for {"adapter"=>"mysql", "host"=>"localhost", "username"=>"root", "password"=>nil, "database"=>"railsproj_development"}, charset: utf8, collation: utf8_general_ci (if you set the charset manually, make sure you have a matching collation) – Zach Inglis Sep 02 '09 at 11:45