新手问题 rake db:create 出错嘛原因。。

surgit · 2013年04月16日 · 最后由 fishinhouse 回复于 2016年10月27日 · 4121 次阅读

[root@li35-175 blog]# rake db:create; rake aborted! (): could not find expected ':' while scanning a simple key at line 10 column 3

Tasks: TOP => db:create => db:load_config (See full trace by running task with --trace)

贴一下 config/database.yml

database.yml 格式错了。

development: adapter: mysql2 database: blog pool: 5 username:root encoding:utf8 host:localhost password:***

这样的。。

对的四楼,,汗,看了半天。

#3 楼 @surgit 一个训练排版的机会,把这段代码排好版吧。

#8 楼 @Rei 好。多谢。

#9 楼 @surgit 我意思是帖子的这段代码用论坛的 Markdown 格式排好版

# MySQL.  Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
#   gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
#   gem 'mysql2'
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html

default:&default
adapter: mysql2
  encoding: utf8
  reconnect: false
  pool: 5
  username: root
  password:yaoqiang
  socket: /var/run/mysqld/mysqld.sock
  # host: 127.0.0.1
  # port: 3306

development:
  <<: *default
  database: rabel_development

# 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:
  <<: *default
  database: rabel_test

root@localhost:~/rabel# RAILS_ENV=production bundle exec rake db:setup rake aborted! Psych::SyntaxError: (): could not find expected ':' while scanning a simple key at line 11 column 1 /usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-1.1.0/lib/figaro/application.rb:60:in parse' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-1.1.0/lib/figaro/application.rb:56:inblock in raw_configuration' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-1.1.0/lib/figaro/application.rb:56:in yield' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-1.1.0/lib/figaro/application.rb:56:inraw_configuration' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-1.1.0/lib/figaro/application.rb:64:in global_configuration' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-1.1.0/lib/figaro/application.rb:32:inconfiguration' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-1.1.0/lib/figaro/application.rb:42:in each' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-1.1.0/lib/figaro/application.rb:36:inload' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-1.1.0/lib/figaro.rb:23:in load' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-1.1.0/lib/figaro/rails/railtie.rb:5:inblock in class:Railtie' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:36:in call' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:36:inexecute_hook' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:45:in block in run_load_hooks' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:ineach' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:in run_load_hooks' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-4.2.0/lib/rails/application.rb:147:inrun_load_hooks!' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-4.2.0/lib/rails/application.rb:95:in instance' /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-4.2.0/lib/rails/railtie.rb:123:inconfig' /root/rabel/config/application.rb:16:in <class:Application>' /root/rabel/config/application.rb:10:inmodule:Rabel' /root/rabel/config/application.rb:9:in <top (required)>' /root/rabel/Rakefile:4:inrequire' /root/rabel/Rakefile:4:in <top (required)>' /usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:ineval' /usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `

' (See full trace by running task with --trace)

帮我看下是什么问题 整个是我的错误信息 藐视不是空格的问题吧?

找不到 host 和 port,去掉前面的#

host: 127.0.0.1 port: 3306

需要 登录 后方可回复, 如果你还没有账号请 注册新账号