在配置PHP与MySQL配合使用时遇到麻烦

编程入门 行业动态 更新时间:2024-10-28 12:20:51
本文介绍了在配置PHP与MySQL配合使用时遇到麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在冒险脱离.NET的世界,进入开放源代码的世界.但是,在尝试设置开发环境时遇到了一些障碍.而且我有点喜欢最新的.

I'm venturing out of the world of .NET and into the world of open-source. However, I've hit a few roadblocks while trying to get my development environment set up. And I'm kind of stuck on the most recent one.

我已经安装:Apache 2.2,php 5.3.2和mySQL 5.1.48 一切都运转良好; apache正在提供PHP页面,并且我能够在mySQL中创建数据库和表,但是,我似乎无法使php与mySQL正确通信.我的php.ini中没有注释以下行:

I have installed: Apache 2.2, php 5.3.2, and mySQL 5.1.48 everything is working pretty much; apache is serving up PHP pages, and I'm able to create databases and tables in mySQL, however, I can't seem to get php to communicate correctly with mySQL. My php.ini has these lines un-commented:

extension=php_mysql.dll extension=php_mysqli.dll

但是,我不断收到此错误消息:

However, I keep getting this error message:

警告:mysqli_connect():(HY000/2002):连接尝试失败,因为一段时间后被连接方未正确响应,或者由于连接的主机未能响应而建立的连接失败.在第15行的C:\ Program Files(x86)\ Apache Software Foundation \ Apache2.2 \ htdocs \ mysql_test.php中

Warning: mysqli_connect(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\mysql_test.php on line 15

任何帮助将不胜感激.

(顺便说一句,当我将其放在Web主机上时php代码可以正常运行)

(btw, the php code runs properly when I put it on my web host)

推荐答案

这很可能是MySql服务器的配置问题.听起来好像是没有在正确的端口上监听,或者连接发生了其他情况.您已正确加载了扩展,因为PHP能够找到mysql函数.我会确保您没有阻止任何必要端口的防火墙(实际上,只需尝试关闭防火墙,看看会发生什么……只是不要忘记将其重新打开;-)).此外,请确保如果您正在遵循的教程完全没有偏离MySQL设置说明.如果这些方法无效,请发布更新,我们可以重试.

This is most likely a configuration problem with the MySql server. It sounds like it either isn't listening on the correct port or something else is going on with the connection. You have the extensions loaded correctly because PHP is able to find the mysql functions. I would make sure you don't have a firewall blocking any of the requisite ports (actually, just try turning off your firewall and see what happens...just don't forget to turn it back on ;-) ). Also make sure if you are following a tutorial you didn't deviate from the MySQL setup instructions at all. If those don't work, post an update and we can try again.

更多推荐

在配置PHP与MySQL配合使用时遇到麻烦

本文发布于:2023-11-24 03:04:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623742.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:麻烦   PHP   MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!