简体   繁体   English

我在localhost上运行服务器时出现问题(ruby on rails)

[英]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.

相关问题 在本地主机上使用数据库的亚马逊AWS服务器,我如何ssh以便我可以在localhost上运行我的php webservices? - Amazon AWS server with database on localhost, how do I ssh so that my php webservices on localhost can run on it? 将本地主机更改为服务器上的主机时,为什么会出错? - Why have error when i change localhost to my host on the server? PHP函数在localhost上运行,但在我的服务器上运行 - PHP function run on localhost but not on my server 当我在数据库中输入connect()时,我的本地主机服务器显示为空白 - When I type in connect() to my database, my localhost server comes up blank 将我的Codeigniter站点从实时服务器移动到本地主机时出现问题 - Problem in moving my Codeigniter site from live server to localhost Ruby on rails连接问题 - Ruby on rails connection problem 当我在Ruby on rails应用程序中将数据转储到我的MySQL表中时,为什么它会显示特殊字符? - When i dump data in my MySQL tables in my Ruby on rails application, why it displays special characters? 当我想连接 mysql 时运行我的应用程序 spring 启动时出现问题 - problem when i run my application spring boot when i want to connect mysql Ruby on Rails不允许我通过localhost:3000运行应用程序 - Ruby on Rails isn't allowing me to run app through localhost:3000 通过ruby Rails迁移添加MySQL枚举列时出现问题 - Problem when adding a MySQL enum column via ruby Rails migration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM