PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #2473

Mysqli (4.1.4gamma) can't connect to 'localhost'

Details

Submitted2004-10-06 23:27 UTC
Frompublic at zonadepruebas dot net
Assigneddanielc
StatusBogus
PackageDB
PHP Version5.0.1
OSMac OS X 10.3.5
Roadmaps(Not assigned)

Comments

[2004-10-06 23:27 UTC] public at zonadepruebas dot net

Description:
------------
When trying to connect to MySQL (4.1.4-gamma-standard)
through PEAR::DB (using mysqli: dns="mysqli://user:
pass@localhost/test") I get a Pear_Error with
getMessage() "DB Error: connect failed" and
getUserInfo() "[nativecode=Can't connect to local MySQL
server through socket '' (2)] ** mysqli://user:
pass@localhost/test".

However, I can connect directly using mysqli:
$i = new mysqli("localhost", "user", "pass", "test");
echo $i->host_info;
// output is "Localhost via UNIX socket"

The solution is giving the real domain or IP of the host
(e.g. 127.0.0.1), then it connects through TCP/IP.

$i = new mysqli("127.0.0.1", "user", "pass", "test");
echo $i->host_info;
// output is "Localhost via TCP/IP"

In this way, I can connect using PEAR::DB.

I am not sure if this is a PEAR:DB bug, a MySQL 4.1.4
bug, a PHP 5.0.1 bug or a Mac OS X bug.

Reproduce code:
---------------
$dblink = DB::connect("mysqli://user:pass@localhost/test");
if (DB::isError(self::$dblink)){
echo "error: ".$dblink->getMessage()." ++ ".$dblink->getUserInfo()
}else{
echo "ok";
}

Expected result:
----------------
"ok"

Actual result:
--------------
error: DB Error: connect failed ++ [nativecode=Can't
connect to local MySQL server through socket '' (2)] **
mysqli://user:pass@localhost/test