Avatar of FirstBorn
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

Hi,

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 2.11.7.1
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:
<code>
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)
</code>

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

I've attempted to use 127.0.0.1 (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:
extension=php_mysql.dll
extension=php_mysqli.dll
... and have stopped and restarted Apache during EVERY Change.

Any Ideas?

Thank you in advance for helping in resolving this issue.

Thanks,
FirstBorn

<?php
 
# 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

PHPMySQL Server

Avatar of undefined
Last Comment
FirstBorn

8/22/2022 - Mon