2011-06-29 6 views
0

皆さん!私は自分のレールアプリケーションのMySQLデータベースをセットアップするのに問題があります。ここに私のdatabase.ymlのファイルの内容は以下のとおりです。Rails rake db:作成しないでください

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


# Warning: The database defined as "test" will be erased and 
# re-generated from your development database when you run "rake". 
# Do not set this db to the same as development or production. 
test: 
  adapter: mysql 
  encoding: utf8 
    reconnect: false 
  database: app_name_test 
  pool: 5 
  username: root 
  password: 
  socket: /tmp/mysql.sock 


production: 
  adapter: mysql 
  encoding: utf8 
    reconnect: false 
  database: app_name_pro 
  pool: 5 
  username: root 
  password: 
  socket: /tmp/mysql.sock 

私も私のgemfileにgem mysqlgem sqlite3を交換しbundle installを走りました。今私はrake db:createで初めてデータベースを作成しようとしています。誰かが私が間違っているのか説明していただけます

$ rake db:create --trace 
(in c:/Users/Kvass/documents/programming/ruby/app_name) 
** Invoke db:create (first_time) 
** Invoke db:load_config (first_time) 
** Invoke rails_env (first_time) 
** Execute rails_env 
** Execute db:load_config 
rake aborted! 
couldn't parse YAML at line 1 column 0 
c:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse' 
c:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse_stream' 
c:/Ruby192/lib/ruby/1.9.1/psych.rb:119:in `parse' 
c:/Ruby192/lib/ruby/1.9.1/psych.rb:106:in `load' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application/configu 
ration.rb:88:in `database_configuration' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/railtie 
s/databases.rake:4:in `block (2 levels) in <top (required)>' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in `call' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in `block in exec 
ute' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in `each' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in `execute' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:597:in `block in invo 
ke_with_call_chain' 
c:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_c 
all_chain' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:607:in `block in invo 
ke_prerequisites' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:604:in `each' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prereq 
uisites' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:596:in `block in invo 
ke_with_call_chain' 
c:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_c 
all_chain' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:583:in `invoke' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task' 

c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 lev 
els) in top_level' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `each' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top 
_level' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exc 
eption_handling' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run 
' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exc 
eption_handling' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:1998:in `run' 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin/rake:31:in `<top (required)>' 

c:/Ruby192/bin/rake:19:in `load' 
c:/Ruby192/bin/rake:19:in `<main>' 

:私は次のエラーを取得していますか?ありがとう!

答えて

1

私はrake db:createを実行しようとしたときにMySQLサーバが私のマシン上で実行されていませんでした。ケアレスミス:私の開発プロセスではP

0

はあなたのdatabase.ymlのようにこれを使用してみてください:

# SQLite version 3.x 
# gem install sqlite3-ruby (not necessary on OS X Leopard) 
development: 
    adapter: sqlite3 
    database: db/development.sqlite3 
    pool: 5 
    timeout: 5000 

# Warning: The database defined as "test" will be erased and 
# re-generated from your development database when you run "rake". 
# Do not set this db to the same as development or production. 
test: &TEST 
    adapter: sqlite3 
    database: db/test.sqlite3 
    pool: 5 
    timeout: 5000 

production: 
    adapter: sqlite3 
    database: db/production.sqlite3 
    pool: 5 
    timeout: 5000 

cucumber: 
    <<: *TEST 
0

私は、この設定を使用します。

development: 
    adapter: mysql2 
    database: my_db 
    encoding: utf8 
    username: rails 
    password: rails 
    host: localhost 
関連する問題