开发者

Error happening when running "rake db:create RAILS_ENV='development' "

I am getting this error in my terminal when I execute the command above,

Deans-MacBook:depot dean$ rake db:create RAILS_ENV='development'
(in /Users/dean/src/RailsBook/depot) Couldn't create database for {"username"=>"root", "adapter"=>"mysql", "database"=>"depot_development", "host"=>"localhost", "password"=>nil}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)

In database config file I have the following:

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

I have the mysql gem installed and now I am unsure on what to do next. I am running Snow Leopard on a Macbook. Why is this error happening?

Edit

Executed the command in the comment and got the following:

Deans-MacBook:depot dean$ rake -t db:create RAILS_ENV='development'
(in /Users/dean/src/RailsBook/depot)
** 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 {"username"=>"root", "adapter"=>"mysql"开发者_JS百科, "database"=>"depot_development", "host"=>"localhost", "password"=>nil}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)

Edit 2

I have uninstalled the mysql gem and reinstalled it and I noticed that an error happened. Here it is:

Deans-MacBook:~ dean$ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...

No definition for next_result

No definition for field_name

No definition for field_table

No definition for field_def

No definition for field_type

No definition for field_length

No definition for field_max_length

No definition for field_flags

No definition for field_decimals

No definition for time_inspect

No definition for time_to_s

No definition for time_get_year

No definition for time_get_month

No definition for time_get_day

No definition for time_get_hour

No definition for time_get_minute

No definition for time_get_second

No definition for time_get_neg

No definition for time_get_second_part

No definition for time_set_year

No definition for time_set_month

No definition for time_set_day

No definition for time_set_hour

No definition for time_set_minute

No definition for time_set_second

No definition for time_set_neg

No definition for time_set_second_part

No definition for time_equal

No definition for error_errno

No definition for error_sqlstate
Installing RDoc documentation for mysql-2.8.1...

No definition for next_result

No definition for field_name

No definition for field_table

No definition for field_def

No definition for field_type

No definition for field_length

No definition for field_max_length

No definition for field_flags

No definition for field_decimals

No definition for time_inspect

No definition for time_to_s

No definition for time_get_year

No definition for time_get_month

No definition for time_get_day

No definition for time_get_hour

No definition for time_get_minute

No definition for time_get_second

No definition for time_get_neg

No definition for time_get_second_part

No definition for time_set_year

No definition for time_set_month

No definition for time_set_day

No definition for time_set_hour

No definition for time_set_minute

No definition for time_set_second

No definition for time_set_neg

No definition for time_set_second_part

No definition for time_equal

No definition for error_errno

No definition for error_sqlstate


Solution upgrade to 64bit version of mysql.


Wild guess -- no password configured on your Mysql instance? Did you try removing the password line from config/database.yml?


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

sudo apt-get install mysql-server mysql-client

and then here are 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 !!! :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜