查询失败:在 sphinx 中连接到 localhost:3306 失败

发布于 2024-10-06 15:03:07 字数 623 浏览 9 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒绊 2024-10-13 15:03:07

谢谢各位,我实际上已经弄清楚了。我使用我的服务器 IP 而不是“localhost”。

Thanks guys, I actually figured it out. I used my server ip instead of "localhost".

小猫一只 2024-10-13 15:03:07

确保您的 sphinx 搜索守护程序正在运行并侦听端口 3306

Make sure your sphinx search daemon is running and listening on port 3306

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文