Avatar of FirstBorn
Flag for United States of America

asked on 

mysql_connect error Can't connect to MySQL server on 'localhost' (10061) and phpmyadmin #2003 - The server is not responding


Thanks for your help.

I am currently on an XP box with the following software specs:
Apache/2.2.9 (Win32) PHP/5.2.6 and mySQL 5.0.51a/phpMyAdmin
I've uninstalled Apache/PHP/mySQL/phpmyadmin
and reinstalled it... No good.

I've SCRUBBED Google and this forum and other forums and none of the
articles worked...

The mySQL Command Line Client works GREAT!
So, mySQL is UP and RUNNING...

Attached is the code that is generating the following error:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10061) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mysql_test1.php on line 9
Can't connect to MySQL server on 'localhost' (10061)

Yes, I've attempted to change hosts and usernames that are in the
user table with all permissions...

I've attempted to use (and similar as mentioned on different EE Articles
for this issue.)

No Firewalls enabled (that I know of...)
Have disabled any type of security setting that I can think of that might block
any connections to the database, as well...

I've created a table called 'test' using the MySQL Command Line Client.
Inside, there is a user - John (as found in a bicubica apache-php-mysql install website.)
It SHOULD be displayed by the script attached to this Q.
I can access the info using the MySQL Command Line Client.

I've attempted to use both (and either of the two) for the php.ini file:
... and have stopped and restarted Apache during EVERY Change.

Any Ideas?

Thank you in advance for helping in resolving this issue.


# Define MySQL Settings
define("MYSQL_HOST", "localhost");
define("MYSQL_USER", "firstborn");
define("MYSQL_PASS", "secret_password");
define("MYSQL_DB", "test");
$conn = mysql_connect("".MYSQL_HOST."", "".MYSQL_USER."", "".MYSQL_PASS."") or die(mysql_error());
mysql_select_db("".MYSQL_DB."",$conn) or die(mysql_error());
$sql = "SELECT * FROM test";
$res = mysql_query($sql);
while ($field = mysql_fetch_array($res))
$id = $field['id'];
$name = $field['name'];
echo 'ID: ' . $field['id'] . '<br />';
echo 'Name: ' . $field['name'] . '<br /><br />';

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon