Cannot connect to database

November 28, 2009 at 14:34:29
Specs: Windows Vista, 2GB
I am getting this Connect Error: 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.

I'm trying to make a connection to the db using this: $db = new mysqli('localhost', 'username', 'password', 'books');
I can log into my DB using the MySQL command line with the root password but for some reason cannot access the database from PHP.
Even when I try to access it with the root like this: $db = new mysqli('localhost', 'root', 'rootpassword', 'books'); it still gives the same error. The database 'books' does exist as I can display it from the command line client.
I'm trying to run this on a Windows Vista machine using IIS 7. Thank you in advance.


See More: Cannot connect to database

Report •


#1
November 29, 2009 at 07:43:38
I found the problem myself. I had to type 127.0.0.1 instead of localhost. I'm not sure why PHP would not translate localhost to 127.0.0.1 but it doesn't.

Report •
Related Solutions


Ask Question