php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44471 mysql_connect times out when a port is specified
Submitted: 2008-03-18 17:57 UTC Modified: 2008-03-20 18:59 UTC
From: jad at hungover dot org Assigned:
Status: Closed Package: MySQL related
PHP Version: 5.2.5 OS: RHEL3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jad at hungover dot org
New email:
PHP Version: OS:

 

 [2008-03-18 17:57 UTC] jad at hungover dot org
Description:
------------
When using mysql_connect with host:port parameter, with port other than 3306, the connection times out.
Am able to telnet to the DB host on the alternative port, with mysql responding as expected.

Tried using latest snapshot, as well as 5.2.5

Reproduce code:
---------------
<?
if( mysql_connect('192.168.151.116:3306','foo','**********') ) {
  print "3306 connected OK\n";
} else {
  print "3306 failed connect\n";
}
if( mysql_connect('192.168.151.116:3307','foo','**********') ) {
  print "3307 connected OK\n";
} else {
  print "3307 failed connect\n";
}
?>


Expected result:
----------------
3306 connected OK
3307 connected OK

Actual result:
--------------
[root@dopey default]# /root/newphp/php5.2-200803181530/sapi/cli/php test.php
3306 connected OK

Warning: mysql_connect(): Can't connect to MySQL server on '192.168.151.116' (4) in /var/www/sites/default/htdocs/test.php on line 7
3307 failed connect
[root@dopey default]#

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-19 00:31 UTC] jad at hungover dot org
Sorry, that made no difference - same results as before.
 [2008-03-20 14:27 UTC] johannes@php.net
Works for me:

php >  var_dump(mysql_connect('192.168.1.102:3308','root','...'));
resource(1) of type (mysql link)


Which libmysql version are you using and might you create a tcpdump log or similar so we can analyze that? Thanks.
 [2008-03-20 18:59 UTC] jad at hungover dot org
Doh...my oops - PHP was picking up some mysql4 libraries...
Thanks for all the help though.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 01 13:01:29 2024 UTC