我之前已经查找了有关Stack溢出的几个问题,无法用我的查询识别出任何问题。我想用我的RoR应用程序设置一个mysql数据库,但会出现以下错误: -
=> Booting WEBrick
=> Rails 2.3.14 application starting on h t t p: / / localhost:3000
/usr/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 6, col 2: ` host: localhost' (ArgumentError)
from /usr/lib/ruby/1.8/yaml.rb:133:in `load'
from /home/sumit/Sites/world_geography/config/../vendor/rails/railties/lib/initializer.rb:926:in `database_configuration'
from /home/sumit/Sites/world_geography/config/../vendor/rails/railties/lib/initializer.rb:437:in `initialize_database'
from /home/sumit/Sites/world_geography/config/../vendor/rails/railties/lib/initializer.rb:141:in `process'
from /home/sumit/Sites/world_geography/config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
from /home/sumit/Sites/world_geography/config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
from /home/sumit/Sites/world_geography/config/environment.rb:9
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:182:in `require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:547:in `new_constants_in'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:182:in `require'
from /home/sumit/Sites/world_geography/vendor/rails/railties/lib/commands/server.rb:84
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from script/server:3
//////////////////////////////////////////////////////////////////////////////////////
ruby -v :-> ruby 1.8.7
rails -v :-> 2.3.14
Also my database.yml file :->
development:
adapter: mysql
database: world_data_dev
username:root
host: local_host
port: 3000
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:
adapter: mysql
database: world_data_test
username:root
host: localhost
port: 3000
pool: 5
timeout: 5000
production:
adapter: mysql
database: world_data_prod
username:root
host: localhost
port: 3000
pool: 5
timeout: 5000
Thanks!
答案 0 :(得分:0)
在您的database.yml文件中,在用户名后面加上空格:
development:
adapter: mysql
database: world_data_dev
username: root
host: local_host
port: 3000
pool: 5
timeout: 5000