查询失败:在 sphinx 中连接到 localhost:3306 失败
我正在尝试使用 sphinx api 从 mysql 数据库获取一些数据,但是当我将其加载到浏览器上时,我不断收到此错误。
查询失败:连接到 本地主机:3306 失败(errno=4,msg=)。
当我尝试将端口号更改为 3312 和其他一些端口号时,我没有运气。
我实际上能够通过 linux 命令获取查询结果,但是当我尝试它时会发生错误(使用 sphinxapi.php文件) 在我的浏览器
代码上:
include('sphinxapi.php');
$cl = new SphinxClient();
$cl->SetServer("localhost", 3306);
$cl->SetMatchMode( SPH_MATCH_ANY );
$result = $cl->Query("email");
if ( $result === false ){
echo "Query failed: " . $cl->GetLastError() . ".\n";
}
else{
print_r($result);
}
我正在使用 sphinx 0.9.8
I'm trying to use the sphinx api to grab some data from a mysql db, but I keep getting this error when I load it on my browser.
Query failed: connection to
localhost:3306 failed (errno=4, msg=).
I had no luck when I tried changing the port number to 3312, and a few others..
I was actually able to get results for queries through linux command, but the error occurs when I try it (using the sphinxapi.php file) on my browser
code:
include('sphinxapi.php');
$cl = new SphinxClient();
$cl->SetServer("localhost", 3306);
$cl->SetMatchMode( SPH_MATCH_ANY );
$result = $cl->Query("email");
if ( $result === false ){
echo "Query failed: " . $cl->GetLastError() . ".\n";
}
else{
print_r($result);
}
I'm using sphinx 0.9.8
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
谢谢各位,我实际上已经弄清楚了。我使用我的服务器 IP 而不是“localhost”。
Thanks guys, I actually figured it out. I used my server ip instead of "localhost".
确保您的 sphinx 搜索守护程序正在运行并侦听端口 3306
Make sure your sphinx search daemon is running and listening on port 3306