1

I recently installed Apache 2 + PHP 5.3.1 + MySQL 5.1.44 on my Windows 7 64bit machine following this guide: http://sleeplessgeek.blogspot.com/2010/01/setting-up-apache-php-mysql-phpmyadmin.html

It all went fine, php is working great (even with XDebug) but I cannot connect to mysql server.

A simple script I wrote to test connection (yes, root has no pass):

    $username = "root";
    $password = "";
    $database = "test";
    $hostname = "localhost";

$conn = mysql_connect($hostname, $username, $password)
    or die("Unable to connect to MySQL Database!!");

It prints this error after 60sec of timeout:

Warning: mysql_connect() [function.mysql-connect]: 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.

I can connect to mysql using cmd>mysql -h localhost -u root

Services are working properly.


There also seems to be a problem with PhpMyAdmin (using 3.2.5). As soon as I type user and pass the page loads and turns blank (content-lenght in headers is 0 but status code is 302 Found). Looks like something wrong with cookies (my auth method).

I hope someone has a clue, it has to be something dumb simple I missed. Thanks in advance.

1

I have this on my machine since upgrading. In my case, specifying 127.0.0.1 as the host instead of localhost does the trick.

One day it will bother me enough to really fix it :)

Edit regarding phpMyAdmin
Ah, phpMyAdmin... yes! I feel your pain. I HATE with a passion every time I am forced to re-install this app. It's a brilliant app when it works, but getting it into a working state has caused me a lot of grief over time.

In my personal experience, make sure all the required PHP modules are loaded and make sure your PHP sessions directory (as specified in php.ini) actually exists on the filesystem. If you change any of those, restart Apache.

Also in my experience, restarting Apache alone is not good enough - a browser restart is needed to properly clear the session.

3
  • Thanks a lot. This is something i haven't thought about! Tried using 127.0.0.1 in address bar (to test phpmyadmin) but not in $host. There's still the problem with phpMyAdmin... I have been using ZendServer recently, with 'localhost' as a mysql host and it worked allright. Now this won't let me sleep :D
    – rszalski
    Mar 1 '10 at 20:56
  • See my edit regarding phpMyAdmin. Mar 1 '10 at 21:09
  • Thank you again! I needed a restart after changing $host in config.inc.php to '127.0.0.1'. Thanks!
    – rszalski
    Mar 1 '10 at 21:19
0

This is a known bug:- http://bugs.php.net/bug.php?id=50172 The solution is to updated your hosts file un-commenting or adding:

127.0.0.1       localhost

Some versions of PHP 5 don't understand windows giving it an IPv6 address

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.