通过自制程序安装的mysql有啥问题
Posted
技术标签:
【中文标题】通过自制程序安装的mysql有啥问题【英文标题】:What is wrong with mysql installed through homebrew通过自制程序安装的mysql有什么问题 【发布时间】:2011-08-21 10:32:24 【问题描述】: Mac 版本:10.6.7 红宝石版本:1.9.2-p180 导轨版本:2.3.5通过brew安装mysql并运行rails服务器后说
/!\ 故障安全 /!\ 2011-05-09 11:18:22 +0545 状态:500 内部服务器错误 无法连接到“127.0.0.1”上的 MySQL 服务器 (61) /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:589:in `real_connect' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:589:in `connect' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:203:in 'initialize' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:75:in `new' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:75:in `mysql_connection' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `block (2 levels) in退房' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `loop' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `block in checkout' /Users/me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `retrieve_connection' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/hoptoad_notifier-2.4.9/lib/hoptoad_notifier/rack.rb:27:in `call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/hoptoad_notifier-2.4.9/lib/hoptoad_notifier/user_informer.rb:12:in `call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/rack-1.0.1/lib/rack/lock.rb:11:in `block in call' :10:在“同步”中 /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `block in call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in `call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `block in call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb:17:in `call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call' /Users/me/.rvm/gems/ruby-1.9.2-p180@suga/gems/rack-1.0.1/lib/rack/handler/webrick.rb:50:in `service' /Users/me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `服务' /Users/me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run' /Users/me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'【问题讨论】:
你可以从 shell 登录 mysql(不使用 Rails)吗? 【参考方案1】:我在你的堆栈跟踪中没有看到 mysql gem,所以我怀疑你可能没有安装它。如果是这样,请将gem 'mysql'
(或gem 'mysql2'
,如果您愿意)添加到您的Gemfile,运行bundle install
并再次启动您的服务器。
此外,请仔细检查您是否确实在运行问题中提到的 Rails 3。堆栈跟踪显示您正在运行 Rails 2.3。同样,在您的 Gemfile 中,确保您有 gem 'rails', '3.0.0'
,然后运行 bundle install
,等等。
【讨论】:
感谢您指出 rails 版本。它是 2.3.5 但错误地是 3.0.0 我怀疑是这样。我最近安装了 Rails 2.3.5,它在安装说明中明确指出该版本的 Rails 中不包含 mysql gem,因此您必须gem install mysql
才能使 MySQL 正常工作。
您还应该确保您实际启动了 MYSql 服务器。以上是关于通过自制程序安装的mysql有啥问题的主要内容,如果未能解决你的问题,请参考以下文章