I recently installed Apache, PHP, and MySQL and all three seem to work fine individually. However, I MySQL and PHP don't seem to be playing well under Apache - when trying to connect to a db, the page hangs for a couple minutes and then finally loads with no content and no error message.

I am running Apache 2.2.14, PHP 5.3.1, and MySQL 5.1.41. I have checked that MySQL is enabled using phpinfo(). All the settings and extensions in php.ini are setup as follows:

mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off

mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off


I've read about problems like this in older versions of PHP related to a DLL in the PHP directory. However, this DLL no longer exists and the issue has supposedly been fixed. Does my setup look ok? Has anyone encountered a problem like this?

  • 3
    Please add the output from your error log with error_reporting set to E_ALL so we can see what PHP is saying about the connection (or lack thereof) – SleighBoy Dec 21 '09 at 7:23
  • Can you connect to MySQL using other programs? I don't know if you can use the mysql command line program on Windows, maybe you should try the MySQL Workbench. If it doesn't work it's a problem with your MySQL configuration. – Felix Dec 21 '09 at 9:18
  • 1
    @Felix: You can connect to MySQL on the command line in Windows using: 'mysql -h <hostname or IP> -u <username> -p' – BenTheDesigner Dec 21 '09 at 11:18

Got the same problem too

You can find solution here:


| improve this answer | |
  1. Enable logging to screen in php.ini as the others have said.
  2. If you have physical logs, look in them to get an idea of the error.
  3. Post everything you find here so we can help out. :)
| improve this answer | |

I can connect to mysql from the command line like BenTheDesigner recommended. I cannot connect within php though. There are no errors in the error log, just messages regarding starting/stopping the server

| improve this answer | |

I found using the stock components from the Microsoft "web platform" downloader I was able to skip all the customized hackery relating to a specific MySQL DLL.

In your PHP scrips, make sure that errors diplay:

error_reporting(E_ALL | E_STRICT );
ini_set('display_errors', '1');

And using mysqli_error() and/or mysqli_connect_error() can help too.

| improve this answer | |

It usually is a good idea to look into apache server logs first, in such cases. For windows, if memory serves, they should be in a folder like: C:\Program Files\Apache Foundation\Apache\logs . Check the error_log file.

Windows Event Logs also may give useful information, which you can access through Windows Management Console / System Tools / Event Viewer / Windows Logs, System and Application logs are relevant.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.