mysql_connect 执行时间较长

发布于 2024-09-08 21:41:48 字数 384 浏览 2 评论 0原文

我在 php 中有以下脚本来登录 mysql

  $db_host="localhost";
  $db_user="root";
  $db_pass="123";

  $dbc=mysql_connect($db_host,$db_user,$db_pass) OR DIE (mysql_error());
  $dbs=mysql_select_db($db_name) OR DIE (mysql_error());    

这个脚本工作正常,现在我重新安装操作系统 现在我有 Windows 7 和 iis7 以及 PHP 版本 5.3.2 和 PHP 5.3.2 版本。 mysql服务器5.1 但现在该脚本无法正常工作并且需要花费日志时间来执行。

谢谢

i have following script in php to login to mysql

  $db_host="localhost";
  $db_user="root";
  $db_pass="123";

  $dbc=mysql_connect($db_host,$db_user,$db_pass) OR DIE (mysql_error());
  $dbs=mysql_select_db($db_name) OR DIE (mysql_error());    

this script was working fine, now i reinstall the O.S
now i have windows 7 and iis7 and PHP Version 5.3.2 & mysql server 5.1
but now this script is not working and taking log time to execute.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

浅唱々樱花落 2024-09-15 21:41:48

在 Windows 7 上 localhost 解析为 ::1,据我所知,MySQL 不支持 IPv6。

直接连接到127.0.0.1可以解决这个问题;但您可以编辑 hosts 文件将 localhost 解析为 127.0.0.1,然后 localhost 也可以工作:

  1. 打开C:\Windows\System32\drivers\etc\hosts
  2. 删除以下行(如果存在): ::1 localhost
  3. 添加以下行(如果不存在): 127.0.0.1 localhost

On Windows 7 localhost resolves to ::1, and MySQL doesn't support IPv6 as far as I know.

Connecting directly to 127.0.0.1 resolves this problem; but you can edit the hosts file to resolve localhost to 127.0.0.1, then localhost will work too:

  1. Open C:\Windows\System32\drivers\etc\hosts
  2. Remove the following line, if present: ::1 localhost
  3. Add the following line, if not present: 127.0.0.1 localhost
染年凉城似染瑾 2024-09-15 21:41:48

使用:(

$db_host = "127.0.0.1";

或任何其他 IP,例如 192.168.1.2),而不是主机名 (localhost)。

Use:

$db_host = "127.0.0.1";

(or any other IP, such as 192.168.1.2), instead of a hostname (localhost).

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