#34072 [Com]: MySQL module can't connect if port is not 3306
| From: | waruiinu at gmail dot com | Date: | Sun, 13 Aug 2006 11:50:40 +0000 |
| Subject: | #34072 [Com]: MySQL module can't connect if port is not 3306 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-100732@lists.php.net to get a copy of this message | ||
ID: 34072
Comment by: waruiinu at gmail dot com
Reported By: pash_ka at fonbet dot info
Status: No Feedback
Bug Type: PDO related
Operating System: Windows XP
PHP Version: 5CVS-2005-08-30
Assigned To: wez
New Comment:
I think there is some sort of bug in mysql client library. It just
doesn't want to use tcp connection if you connect to localhost. For
example if I add -P 3306 to mysql client binary, netstat will show the
unix connection, not the tcp. Only if i use -h 127.0.0.1 mysql will use
tcp (-h localhost doesn't solve anything).
Previous Comments:
------------------------------------------------------------------------
[2005-09-08 01:00:03] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2005-08-31 06:07:52] gschlossnagle@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
try a new 5.1 snapshot please. Your bug is only occurs when
you use 'localhost' (and not 127.0.0.1), so please check that.
Thanks,
George
------------------------------------------------------------------------
[2005-08-30 12:22:20] pash_ka at fonbet dot info
I've also checked it with version 5.1.0b3 (Jul 14 2005 20:32:24), and
it works fine for 127.0.0.1
------------------------------------------------------------------------
[2005-08-30 12:00:23] pash_ka at fonbet dot info
I've tried it with latest (Aug 30 2005 08:37:40) build, and using
127.0.0.1 instead of localhost works.
I'm using this test script:
-------------------------------------------
<?php
if(!isset($argv)){
header('Content-type: text/plain');
header("Content-Disposition: inline; filename=dbotest.txt");
}
$cfg['host'] = 'localhost';
//$cfg['host'] = '127.0.0.1';
$cfg['port'] = 6733;
$cfg['database'] = 'www-new';
$cfg['username'] = 'pasha';
$cfg['password'] = '****';
connect_mysql($cfg);
echo "\n";
connect_pdo_mysql($cfg);
function connect_mysql($cfg){
$dsn = $cfg['host'].':'.$cfg['port'];
echo "Connecting to MYSQL (DSN = {$dsn}).\n";
@$res = mysql_connect($dsn, $cfg['username'], $cfg['password']);
echo 'Result: '.($res?'OK':mysql_error())."\n";
return $res;
}
function connect_pdo_mysql($cfg){
$dsn =
"mysql:host={$cfg['host']};port={$cfg['port']};dbname={$cfg['database']}";
echo "Connecting to PDO_MYSQL (DSN = {$dsn}).\n";
try{
$res = new PDO($dsn, $cfg['username'], $cfg['password']);
echo "Result: OK\n";
return $res;
}catch(PDOException $ex){
echo 'Result: '.$ex->getMessage()."\n";
return false;
}
}
?>
-------------------------------------------
And this is the result when using localhost:
------------------------------------------
Connecting to MYSQL (DSN = localhost:6733).
Result: OK
Connecting to PDO_MYSQL (DSN =
mysql:host=localhost;port=6733;dbname=www-new).
Result: SQLSTATE[HY000] [2003] Can't connect to MySQL server on
'localhost' (10061)
------------------------------------------
------------------------------------------------------------------------
[2005-08-30 01:05:46] iliaa@php.net
Does it work if you change the hostname to 127.0.0.1?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/34072
--
Edit this bug report at http://bugs.php.net/?id=34072&edit=1