|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-04-09 03:20 UTC] wez@php.net
[2006-10-30 12:56 UTC] gilcher at exozet dot com
[2008-05-08 10:53 UTC] johannes at schlueters dot de
[2008-05-08 10:54 UTC] johannes at schlueters dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 09:00:02 2025 UTC |
Description: ------------ We have two instances of mysql running, 4.1x on port 3306 using /tmp/mysql.sock and 5.0.18 on port 3307 using /tmp/mysql5.0.18/mysql.sock. If I connect using the dsn and specify the port, like so: $db = new PDO('mysql:host=localhost;port=3306;dbname=dbname', 'user', 'pass'); I actually connect to the 5.0.18 instance on 3307. I know this based on the results of the query executed later. If, however, I connect using the unix_socket parameter and point it at the 3306 socket file, it seems to work correctly. Again, I know this because the results of the query are correct. I wouldn't rule out configuration problems on my end, but even if that were the case it would appear you cannot specify a port to override a configuration value Reproduce code: --------------- mysql on 3306 (/tmp/mysql.sock) select count(*) from users; //result 5 mysql on 3307 (/tmp/mysql5.0.18/mysql.sock) select count(*) from users; //result 2 $db = new PDO('mysql:host=localhost;port=3306;dbname=dbname', 'user', 'pass'); $result = $db->query("select count(*) from users"); print_r($result); //Array ( [count(*)] => 2 [0] => 2 ) //expecting 5 $db = new PDO('mysql:unix_socket=/tmp/mysql.sock;dbname=dbname', 'user', 'pass'); $result = $db->query("select count(*) from users"); print_r($result); //Array ( [count(*)] => 5 [0] => 5 ) Expected result: ---------------- I expect unix_socket=/tmp/mysql.sock and port=3306 to produce the same results. Actual result: -------------- when specifying a port number as part of the dsn it does not seem to be honored.