通过mysql协议连接到Sphinx导致“No database selected”错误

时间:2012-10-23 13:17:31

标签: sphinx mysql

我尝试连接到正在运行的sphinx实例,它连接正常:

XXX@XXX:~$ mysql -P 9306
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 52
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

但是没有SELECT可以执行。我收到“数据库未选中”错误。然后我试图杀死sphinxd并在杀死它之后我无法连接到端口9306,所以我假设,我连接正常... 为什么我不能从索引中选择数据?我确认了多次,索引存在且可以搜索。

1 个答案:

答案 0 :(得分:4)

我找到了原因。如果您仔细查看服务器版本,您将看到:

 Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)

所以我连接到Mysql而不是sphinx。为什么?因为我没有指定主机,它在'/var/run/mysqld/mysqld.sock'上使用了mysql套接字。您需要正确指定主机:

XXX@XXX:~$ mysql -P 9306 -h 127.0.0.1
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 2.0.5-id64-release (r3308)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>