首页 > 解决方案 > 无法将 mySQL 连接到 Sphinx 搜索

问题描述

我正在使用最新版本的 mySQL 服务器,我希望将它连接到 Sphinx Search。但是,当我尝试使用“SphinxQL”通过 CMD 连接到服务器时,我遇到:

ERROR 200 (HY000): Unknown MySQL error

这是通过尝试:

searchd -P9306

并接收:

[Wed Aug 29 10:41:28.893 2018] [22560] listening on 127.0.0.1:9312
[Wed Aug 29 10:41:28.893 2018] [22560] listening on all interfaces, port=9306
[Wed Aug 29 10:41:28.959 2018] [22560] WARNING: No extra index definitions found in data folder
[Wed Aug 29 10:41:28.965 2018] [22560] accepting connections
[Wed Aug 29 10:41:28.966 2018] [21976] prereading 2 indexes
[Wed Aug 29 10:41:28.966 2018] [21976] prereaded 2 indexes in 0.000 sec

但是,我可以以相同的方式连接到端口 3306 并成功进入基础 mySQL 服务器。我听说 Sphinx 和 SQL 保存密码的方式有些不同,所以我使用了 mysql_native_password 和较新版本的用户都无济于事。

索引器运行良好,但是当我专门旋转索引时,我遇到了关于无法打开 pid_file 的错误。这可能不相关。

下面是我的代码片段:

#
# Minimal Sphinx configuration sample (clean, simple, functional)
#

source src1
{
    type            = mysql

    sql_host        = localhost
    sql_user        = test
    sql_pass        = test123
    sql_db          = test
    sql_port        = 3306  # optional, default is 3306

    sql_query       = SELECT id, name, storage, colour, network, quality, price, UNIX_TIMESTAMP() AS last_modified FROM phones
    # UNIX_TIMESTAMP() AS

    sql_attr_timestamp  = last_modified
}


index test1
{
    source          = src1
    path            = C:/Program Files/sphinx-3.0.3/data/test1
}


index testrt
{
    type            = rt
    rt_mem_limit    = 128M

    path            = C:/Program Files/sphinx-3.0.3/data/testrt

    rt_field        = id
    rt_field        = name
    rt_field        = storage
    rt_field        = colour
    rt_field        = network
    rt_field        = condition
    rt_field        = price
    rt_field        = last_modified
    rt_attr_uint    = gid
}


indexer
{
    mem_limit       = 128M
}


searchd
{
    mysql_version_string = 5.0.37
    listen          = localhost:9312
    listen          = 9306:mysql41
    log         = C:/Program Files/sphinx-3.0.3/log/searchd.log
    query_log       = C:/Program Files/sphinx-3.0.3/log/query.log
    read_timeout        = 5
    max_children        = 30
    pid_file        = C:/Program Files/sphinx-3.0.3/log/searchd.pid
    seamless_rotate     = 1
    preopen_indexes     = 1
    unlink_old      = 1
    workers         = threads # for RT to work
    binlog_path     = C:/Program Files/sphinx-3.0.3/data
}

标签: mysqlwindowssearchsphinx

解决方案


看起来您正在使用 mysql 8 客户端。狮身人面像尚不兼容。您可能想尝试 Manticore Search(Sphinx 的一个分支)。

[root@sehs01 mysql-8.0.11-el7-x86_64]# ./bin/mysql --version
./bin/mysql  Ver 8.0.11 for el7 on x86_64 (MySQL Community Server - GPL)

[root@sehs01 mysql-8.0.11-el7-x86_64]# ./bin/mysql -hse01 -P6312
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 2.7.2 58d96fd@180822 dev

推荐阅读