php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31220 bloated localhost connection
Submitted: 2004-12-21 06:19 UTC Modified: 2004-12-21 14:38 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: bc at default dot co dot yu Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.3.10 OS: Linux 2.4
Private report: No CVE-ID: None
 [2004-12-21 06:19 UTC] bc at default dot co dot yu
Description:
------------
I'm using recent 4.3.10 release with mysql 4.1 client libs.

I have a configuration of 2 servers. One is the MySQL database, another is apache 1.3 running PHP 4.3.10 through CGI/FastCGI interface.

All scripts are using "localhost" value in mysql_connect() function. Actually that connection is being NAT'ed with iptables to MySQL server.

When I do manual connect with telnet to localhost:3306 it works fine. Also if "localhost" is changed  to "127.0.0.1" or  direct IP of MySQL host ( 10.1.5.55 in this case ) it just works fine!
*But* when is "localhost" in mysql_connect() it simply does NOT work!

Reproduce code:
---------------
I keep getting this: 
Access denied for user: 'username@10.1.5.89' (Using password: NO)


keep in mind that I *am* providing the password:
$db = mysql_connect("localhost", "$db_username", $db_password);

this is my /etc/hosts file:
127.0.0.1	localhost localhost.localdomain

BTW, I've tried all the combinations:
127.0.0.1	localhost
or:
127.0.0.1	localhost.localdomain


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-21 07:40 UTC] sniper@php.net
RTFM: http://www.php.net/mysql_connect

"Note:  Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket..."

Read the rest from the manual page..

 [2004-12-21 13:49 UTC] bc at default dot co dot yu
but can it be fixed by some workaround. I need it really bad, because there's hundreds of scripts with "localhost" in it and it couldn't be easy to change all of them to "127.0.0.1" or whatever else.

10x in advance
 [2004-12-21 14:38 UTC] bc at default dot co dot yu
maybe to disable unix domain socket in mysql client?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 04:01:38 2024 UTC