Вопрос

I get the error "Warning: mysqli::mysqli(): (HY000/2005): Unknown MySQL server host '127.0.0.1:9306' (0)". According to the netstat command the port 9306 is open but it can't connect via PHP or the command prompt. The command prompt connects to MySQL on port 9306 instead of connecting to sphinx.

The code that causes this is:

$sphinx = new mysqli('127.0.0.1:9306');

This is on Linux and the Sphinx version is 2.0.4. Other versions including 2.2.1 have been tried.

Can anyone help me get this working?

This is my first question so let me know if I need to change the format of this question.

Это было полезно?

Решение

Re the command-line client, you probably need to explicitally tell it use tcp

mysql -P 9306 --protocol=tcp

Its counter-intutive, that the mysql client will silentiy ignore the -P param, if it finds a mysql server on the local machine.

And as for PHP, no idea if what you have should work, but I tend to use

$sphinx = new mysqli("127.0.0.1", "", "", "", 9306);

which works for me.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top