gpt4 book ai didi

mysql - 无法使用 ruby​​-mysql gem 连接到 MySQL

转载 作者:数据小太阳 更新时间:2023-10-29 08:28:15 26 4
gpt4 key购买 nike

我使用 bundler 安装了 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。我该如何解决这个问题?

谢谢

最佳答案

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

尝试改变它

/tmp/mysql.sock

/var/run/mysqld/mysqld.sock

关于mysql - 无法使用 ruby​​-mysql gem 连接到 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12704588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com