0

我想继续编写铁路应用程序,但是当我尝试启动服务器时出现以下错误rails s

当我有一个全新的目录(它在那里使用 sqlite3)时,我的导轨安装似乎工作正常。我也可能安装了所有东西,xcode,自制软件,RVM ......

操作系统:OS X,1.8.2

有什么想法可以解决这个错误吗?

/Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (Mysql2::Error)
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
    from /Users/myself/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
    from /Users/myself/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/model_schema.rb:308:in `clear_cache!'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/railtie.rb:97:in `block (2 levels) in <class:Railtie>'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:418:in `_run__4072264347074867870__prepare__1617522906049658136__callbacks'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.9/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.9/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `run'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `each'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/application.rb:136:in `initialize!'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/myself/events/config/environment.rb:5:in `<top (required)>'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
    from /Users/myself/events/config.ru:4:in `block in <main>'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
    from /Users/myself/events/config.ru:1:in `new'
    from /Users/myself/events/config.ru:1:in `<main>'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/commands/server.rb:46:in `app'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/commands/server.rb:70:in `start'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/commands.rb:50:in `tap'
    from /Users/myself/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
4

1 回答 1

0

osx上的位置不同,查找/private/var/mysql/mysql.sock

您的选择是更改 database.yml 中的套接字值或在 /tmp/myslq.sock 创建符号链接

我更喜欢后者,因为这是一个常见问题。

于 2012-12-07T20:02:25.500 回答