【问题标题】:Can't connect to MySQL server on '127.0.0.1' (61) rails thinking_sphinx无法连接到 '127.0.0.1' (61) rails thinking_sphinx 上的 MySQL 服务器
【发布时间】:2013-07-30 01:04:07
【问题描述】:

我正在从 thinking_sphinx ~2.5 升级到 3.0.3,以遵循 heroku 插件 fly_sphinx 的设置说明。升级可能根本没有必要,但现在我已经完成了,所以最好完成它。

当我尝试搜索时(例如 Post.search("search term")),我得到以下信息:

Can't connect to MySQL server on '127.0.0.1' (61)

我用 post_index.rb 设置了我的索引文件夹

ThinkingSphinx::Index.define :post, :with => :active_record do
  (. . . code here . . .)
end

我有我的 config/thinking_sphinx.yml 文件

development:
 version: 3.0.3
 mysql41: 9110
 morphology: stem_en
 html_strip: 1
 min_infix_len: 2
 bin_path: "/usr/local/bin"
 searchd_binary_name: searchd
 indexer_binary_name: indexer
 host: 127.0.0.1
test:
 version: 3.0.3
 mysql41: 9110
 morphology: stem_en
 html_strip: 1
 min_infix_len: 2
production:
 version: 3.0.3
 mysql41: 9110
 morphology: stem_en
 html_strip: 1
 min_infix_len: 2

和 Gemfile

gem 'mysql2',          '0.3.12b5'
gem 'thinking-sphinx', '3.0.3' #'2.0.11'
gem 'flying-sphinx',   '1.0.0' #'0.8.4'

我在本地和 heroku 上运行 postgres

谢谢!

编辑

现在我的 thinking_sphinx.yml 看起来像这样:

development:
  mysql41: 9110
  morphology: stem_en
  html_strip: 1
  min_infix_len: 2
  bin_path: "/usr/local/bin"
  host: 127.0.0.1
test:
  mysql41: 9111
  morphology: stem_en
  html_strip: 1
  min_infix_len: 2
production:
  morphology: stem_en
  html_strip: 1
  min_infix_len: 2

当我试图 searchd 当前未运行。

Stopped searchd daemon (pid: ).
Generating configuration to /Users/Achilles/Desktop/dev/mocs/config/development.sphinx.conf
Sphinx 2.0.6-release (r3473)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/blah/blah/blah/development.sphinx.conf'...
indexing index 'post_core'...
ERROR: index 'post_core': infixes and morphology are enabled, enable_star=0
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
Failed to start searchd daemon. Check /Users/Achilles/Desktop/dev/mocs/log/development.searchd.log.
Failed to start searchd. Check the log files for more information.

【问题讨论】:

    标签: ruby-on-rails-3 thinking-sphinx


    【解决方案1】:

    您需要更改以下内容:

    • 从您的thinking_sphinx.yml 文件中删除version 设置。此设置用于明确您使用的是哪个版本的 Sphinx,而不是Thinking Sphinx
    • 更新到 TS v3.0.4 - 可能不重要,但使用最新版本并没有什么坏处。
    • 不要为您的生产环境设置 mysql41 - 最好为每个开发和测试设置为不同的值 - 这样守护程序可以同时在两个环境中运行。
    • 您还可以删除 *_binary_name 设置 - 如果您将它们设置为默认值,那么没有多大意义。

    一旦这一切都改变了,运行 rake ts:rebuild 并查看是否可以连接...但在这一点上,有必要澄清一下您是在本地还是在 Heroku 上看到此问题?

    【讨论】:

    • 谢谢!我现在在本地看到问题。我们待会儿再看。事情仍然无法正常工作:o(。查看我的编辑
    • 对。如果您使用中缀或前缀,我认为 Sphinx 还要求您将 enable_star 设置为 true。将其添加到 config/thinking_sphinx.yml 中的每个环境中,看看是否有帮助。
    • 成功了!谢谢。现在我遇到了另一个问题。 stackoverflow.com/questions/17963593/…
    猜你喜欢
    • 2015-11-24
    • 1970-01-01
    • 2014-12-08
    • 2012-02-08
    • 1970-01-01
    • 2014-06-25
    • 2014-08-22
    相关资源
    最近更新 更多