Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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]
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]
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

[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll

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?

share|improve this question

migrated from stackoverflow.com Dec 21 '09 at 12:00

This question came from our site for professional and enthusiast programmers.

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

5 Answers 5

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

share|improve this answer

Got the same problem too

You can find solution here:

http://uk.php.net/manual/en/function.mysql-connect.php#94316

share|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.

share|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. :)
share|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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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