Taras Voinarovskyi
Taras Voinarovskyi

Reputation: 176

Connect to Sphinx through mysql protocol result in "No database selected" error

I tried connecting to a running sphinx instance and it connects normal:

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> 

But no SELECT could be executed. I got "database not selected" error. Then I tried to kill sphinxd and after killing it I could not connect to port 9306, so I assumed, that I connected normaly... Why can't I do select data from index? I confirmed many times and the index is present and is searchable.

Upvotes: 2

Views: 7381

Answers (1)

Taras Voinarovskyi
Taras Voinarovskyi

Reputation: 176

I found the reason. If you looked carefuly at the server version you will see:

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

So I connected to Mysql instead of sphinx. Why? Because I did not specify the host and it used mysql socket at '/var/run/mysqld/mysqld.sock'. You need to specify the host correctly:

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> 

Upvotes: 4

Related Questions