简体   繁体   English

ruby on rails $ mysql

[英]ruby on rails $ mysql

I am configure the mysql instead of sqlite3 and the output is : 我配置mysql而不是sqlite3,输出是:

=> Booting WEBrick    
=> Rails 2.3.11 application starting on http://0.0.0.0:3000   
C:/Ruby192/lib/ruby/1.9.1/syck.rb:135:in `load': syntax error on line 24, col 18: `' (ArgumentError)   
        from C:/Ruby192/lib/ruby/1.9.1/syck.rb:135:in `load'  
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.11/lib/initializer.rb:927:in `database_configuration'  
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.11/lib/initializer.rb:437:in `initialize_database'   
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.11/lib/initializer.rb:141:in `process'   
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.11/lib/initializer.rb:113:in `run'  
        from C:/rails/rail/config/environment.rb:9:in `<top (required)>'    
        from <internal:lib/rubygems/custom_require>:29:in `require'  
        from <internal:lib/rubygems/custom_require>:29:in `require'  
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport2.3.11/lib/active_support/dependencies.rb:182:in `block in require'  
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport2.3.11/lib/active_support/dependencies.rb:547:in `new_constants_in'  
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport2.3.11/lib/active_support/dependencies.rb:182:in `require'  
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.11/lib/commands/server.rb:84:in `<top (required)>'  
        from <internal:lib/rubygems/custom_require>:29:in `require'  
        from <internal:lib/rubygems/custom_require>:29:in `require'  
        from script/server:3:in `<main>'

Could someone tell me what is wrong here? 有人能告诉我这里有什么问题吗? It seems like there is something wrong with the code because it doesn't work. 似乎代码有问题,因为它不起作用。 I will appreciate a lot the help from yours 我非常感谢你的帮助

here is my yml file for mysql 这是我的mysql的yml文件

development:      
adapter: mysql   
database: test  
username:false  
password:neha  
host :localhost  
port:3306 

use above tab sequence in all of your environment 在您的所有环境中使用选项卡序列

development:
 adapter: mysql
 database: test
 username:false
 password:neha
 host :localhost
 port:3306 

Couple of issues: 几个问题:

  1. host :localhost should be host: localhost . host :localhost应该是host: localhost Note the position of the : character - having it after the space is what gives you that syntax error. 注意:字符的位置 - 在空格之后使用它会导致语法错误。 I get exactly the same stacktrace if the YAML is set up as you have it. 如果你已经设置了YAML,我会得到完全相同的堆栈跟踪。

  2. You need to indent the attributes of the development hash. 您需要缩进development哈希的属性。 This won't make the YAML invalid, but it will give you the wrong result. 这不会使YAML无效,但它会给你错误的结果。 If you don't indent, you'll get a series of key => value hashes, instead of a hash containing a development key, which in turn has child attributes for the configuration params. 如果你没有缩进,你将获得一系列key =>值哈希,而不是包含development键的哈希,而development键又包含配置参数的子属性。

There's something wrong with your YAML configuration. 您的YAML配置有问题。 Syck is YAML parser that fails to load YAML configuration files. Syck是无法加载YAML配置文件的YAML解析器。 Check the configuration for typos, especially config/database.yml . 检查拼写错误的配置,尤其是config / database.yml

Also, use username:"false" in your configuration. 另外,在配置中使用username:"false" true of false without quotes will be interpreted as TrueClass , not String , and that might cause trouble. 如果没有引号,则false将被解释为TrueClass ,而不是String ,这可能会导致麻烦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM