2009年4月27日星期一

Re: [fw-db] Two MySQL database processes on ports 3306 and 3307

On Mon, Apr 27, 2009 at 9:33 AM, Christian Welzel <gawain@camlann.de> wrote:
> Am Montag 27 April 2009 schrieb rhodium:
>
>> Is it possible to connect to the two separate database processes on the
>> same machine using Zend Framework. Apparently the port number is being
>> ignored when using Zend_Db and PDO.
>
> This is an issue of the mysql php driver.
> It overrides all port settings if you use the string "localhost" as server
> name. If you want to use another port, then you have to use the
> ip address "127.0.0.1" as host name.

I know that ext/mysql assumes socket, when you say 'localhost'. So I
guess if you point it to another socket (of the 2nd mysqld) and it
could work without TCP/IP.

Also, I wasn't sure if ext/mysqli, let alone PDO follow this? There's
nothing in the manual. But you could try something like that:

$db = new mysqli('localhost:3306', 'root', '', 'mysql');
echo 'Success... ' . $db->host_info . "\n";
$db->close();

$db = new mysqli('localhost:3307', 'root', '', 'mysql');
echo 'Success... ' . $db->host_info . "\n";
$db->close();

This should let you know how it connected.

没有评论: