我对使用Ruby on Rails来运行站点非常陌生。一个小小的背景故事:
所以我正在做一个项目,我已经得到了这个网站的代码。我使用的是Windows,所以我知道它不是最好的RoR操作系统,但换个不同的操作系统对我来说是最后的选择。
我从railsinstaller.org那里得到了RailsInstaller,并运行了它。一切都安装得很顺利。
我从我的站点目录中运行bundle install,遇到了gem "therubyracer“的问题。我对此进行了大量搜索,发现Windows并不需要这个宝石。我认为。因此,我在Gemfile中注释掉了gem,并再次运行bundle install。一切都安装得很好。
我尝试通过命令提示符运行rails s,但收到一个错误:
The program can't start because LIBMYSQL.dll is missing from your computer.所以我对此做了一些研究,发现我必须将文件复制到RailsInstaller目录下的Ruby/bin文件夹中。错误消失了。
最后,我再次运行rails s,服务器被放在本地主机下。我认为。不管怎样,我去了localhost:3000,收到了一个MySQL2::Error和Can't connect to MySQL server on 'localhost' (10061)。当我单击Full Trace时,我会得到如下代码:
development/ruby/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/client.rb:44:in `connect'
development/ruby/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/client.rb:44:in `initialize'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:303:in `new_connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:313:in `checkout_new_connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:237:in `block (2 levels) in checkout'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:232:in `loop'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:232:in `block in checkout'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `checkout'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `retrieve_connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/query_cache.rb:67:in `rescue in call'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/query_cache.rb:61:in `call'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:467:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
development/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `_run__132547094__call__984979790__callbacks'
development/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `__run_callback'
development/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
development/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:65:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
development/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/logger.rb:26:in `call_app'
development/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/logger.rb:16:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/request_id.rb:22:in `call'
development/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
development/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
development/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
development/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/static.rb:62:in `call'
development/ruby/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:479:in `call'
development/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:220:in `call'
development/ruby/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
development/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb:14:in `call'
development/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'我对此进行了一些调查,发现了Rails development - Can't connect to MySQL server on 'localhost' (10061)。
当我在命令提示符上尝试ping localhost时,我得到了顶部注释所说的内容:
Reply from ::1: time<1ms并且我不确定如何更改配置以使主机成为127.0.0.1。
抱歉,这段时间有点长,我不确定它有多大帮助。正如我在标题中所说的,我对此非常陌生--我仍然不确定什么是host。
我真的只想让这个网站运行起来,这样我就可以开始工作了。我做的一切都是对的吗?我真的需要therubyracer吗?我做了什么/没有做什么可以帮助我开始使用它?错误显示的是什么问题?
如果还有什么需要我提供的,请告诉我!谢谢你的帮助!
发布于 2012-11-21 03:01:37
您可以使用MySQL workbench检查服务器状态。
DBMS的配置是在Rails项目的db/database.yml文件中设置的。
我建议您阅读一些关于Rails的知识,以及关于数据库存储的一般知识。您可以从使用SQLite的this tutorial开始。MySQL和SQLite是不同风格的RDBMS,Rails通常使用它们来存储需要长期保存的信息。
https://stackoverflow.com/questions/13479029
复制相似问题