[英]Problem when I run my server on localhost (ruby on rails)
When I type rails server in my CMD the server works and I can go to localhost:3000. 当我在我的CMD中键入rails服务器时服务器工作,我可以转到localhost:3000。 But after i get this messege in the CMD and the same message in the browser on localhost:3000 in the errors section.
但是我在CMD中获得了这个消息,并且在错误部分的localhost:3000上的浏览器中显示了相同的消息。
Started GET "/rails/info/properties" for 127.0.0.1 at 2010-12-02 21:14:55 +0200
Mysql2::Error (Access denied for user 'root'@'localhost' (using password: NO)):
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_dispatc
h/middleware/templates/rescues/_trace.erb (1.0ms)
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_dispatc
h/middleware/templates/rescues/_request_and_response.erb (30.0ms)
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_dispatc
h/middleware/templates/rescues/diagnostics.erb within rescues/layout (97.0ms)
What is the issue? 有什么问题?
here this is the database.yml file: 这是database.yml文件:
# MySQL.
#MySQL。 Versions 4.1 and 5.0 are recommended.
建议使用版本4.1和5.0。 # # Install the MySQL driver: # gem install mysql2 # # And be sure to use new-style password hashing: # http://dev.mysql.com/doc/refman/5.0/en/old-client.html development: adapter: mysql2 encoding: utf8 reconnect: false database: simple_cms_development pool: 5 username: root password: host: localhost
##安装MySQL驱动程序:#gem install mysql2 ##并确保使用新式密码哈希:#http: //dev.mysql.com/doc/refman/5.0/en/old-client.html开发: adapter:mysql2编码:utf8 reconnect:false database:simple_cms_development pool:5用户名:root密码:host:localhost
# 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.
#不要将此db设置为与开发或生产相同。 test: adapter: mysql2 encoding: utf8 reconnect: false database: simple_cms_test pool: 5 username: root password: host: localhost
test:adapter:mysql2编码:utf8 reconnect:false database:simple_cms_test pool:5用户名:root密码:host:localhost
production: adapter: mysql2 encoding: utf8 reconnect: false database: simple_cms_production pool: 5 username: root password:passwordex host: localhost
I know you already found the solution to your problem, but I'm going to post this as an answer anyways, for those who might stumble across this same issue. 我知道你已经找到了你的问题的解决方案,但无论如何我会发布这个答案,对于那些可能会遇到同样问题的人。
Having the same exact Access denied for user 'user'@'localhost' (using password: NO)
problem, it turns out my database.yml
file was malformatted. Access denied for user 'user'@'localhost' (using password: NO)
问题具有相同的准确Access denied for user 'user'@'localhost' (using password: NO)
,但事实证明我的database.yml
文件格式错误。 The reason? 原因? YAML doesn't allow certain characters: I happened to be using a '!'
YAML不允许某些字符:我碰巧使用了'!' in my password, and for whatever reason, the YAML parser reading this
database.yml
file ignored my password line like it wasn't there, hence the (using password: NO)
, even though I explicitly declared it. 在我的密码中,无论出于何种原因,读取此
database.yml
文件的YAML解析器忽略了我的密码行,就像它不存在一样,因此(using password: NO)
,即使我明确声明它。
Solution? 解? Changed my password not to include any YAML special characters.
更改了我的密码,不包括任何YAML特殊字符。 I suppose there might be a way to escape it, though.
不过,我想可能有办法逃脱它。 Annoying nonetheless.
尽管很恼火。
You're using root for your mysql user, but not supplying the root password in config/database.yml. 您正在为您的mysql用户使用root,但不在config / database.yml中提供root密码。
Incidentally, while its usually ok in development, using the root mysql user in production or for staging is a Very Bad Idea™. 顺便提一下,虽然它通常可以开发,但是在生产中使用root mysql用户或者进行分段是一个非常糟糕的想法。
here's a typical mysql config section: 这是一个典型的mysql配置部分:
production:
adapter: mysql
database: app_production
username: root
password: password
pool: 5
timeout: 5000
encoding: utf8
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.