2

我使用捆绑器安装了 ruby​​-mysql gem。但是 Mysql.connect 因以下跟踪而崩溃。

/home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/ruby-mysql-2.9.10/lib/mysql/protocol.rb:167:in `initialize': No such file or directory - /tmp/\
mysql.sock (Errno::ENOENT)
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/ruby-mysql-2.9.10/lib/mysql/protocol.rb:167:in `new'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/ruby-mysql-2.9.10/lib/mysql/protocol.rb:167:in `block in initialize'
        from /home/kris/.rvm/rubies/ruby-1.9.3-p194-perf/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/ruby-mysql-2.9.10/lib/mysql/protocol.rb:164:in `initialize'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/ruby-mysql-2.9.10/lib/mysql.rb:114:in `new'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/ruby-mysql-2.9.10/lib/mysql.rb:114:in `connect'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/ruby-mysql-2.9.10/lib/mysql.rb:49:in `new'
        from /home/kris/dev/dispatch/application.rb:38:in `<top (required)>'
        from config.ru:1:in `require'
        from config.ru:1:in `block in <main>'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/rack-1.3.6/lib/rack/builder.rb:51:in `instance_eval'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize'
        from config.ru:1:in `new'
        from config.ru:1:in `<main>'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/thin-1.4.1/lib/rack/adapter/loader.rb:33:in `eval'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/thin-1.4.1/lib/rack/adapter/loader.rb:33:in `load'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/thin-1.4.1/lib/thin/controllers/controller.rb:181:in `load_rackup_config'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/thin-1.4.1/lib/thin/controllers/controller.rb:71:in `start'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/thin-1.4.1/lib/thin/runner.rb:185:in `run_command'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/thin-1.4.1/lib/thin/runner.rb:151:in `run!'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/gems/thin-1.4.1/bin/thin:6:in `<top (required)>'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/bin/thin:23:in `load'
        from /home/kris/.rvm/gems/ruby-1.9.3-p194-perf@dispatch/bin/thin:23:in `<main>'

我的机器运行的是 Ubuntu 12.04,我已经安装了 libmysqlclient-dev。我该如何解决这个问题?

谢谢你

4

1 回答 1

6

我相信您应该只更改 database.yml 中的套接字。

尝试从

/tmp/mysql.sock

/var/run/mysqld/mysqld.sock

于 2012-10-03T09:09:32.170 回答