在配置PHP与MySQL配合使用时遇到麻烦 [英] Having troubles configuring PHP to work with mySQL

查看:62
本文介绍了在配置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配合使用时遇到麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆