|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-04-27 21:17 UTC] murphy at renkoo dot net
[2005-04-28 11:44 UTC] george at omniti dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sat Jan 03 20:00:01 2026 UTC |
Description: ------------ There's a one line bug in mysql_driver.c in PDO_MYSQL 0.2 which prevents connections to localhost over the local unix socket. The code tests for the hostname localhost and passes the driver the string "." as the hostname if it matches. However, the mysql C api specifies that the hostname for local socket connections should be "localhost" or NULL. Here's a patch: --- mysql_driver.c Sun Feb 6 15:22:37 2005 +++ mysql_driver.c.patched Wed Apr 27 17:57:03 2005 @@ -276,7 +276,7 @@ host = vars[2].optval; port = atoi(vars[3].optval); } else { - host = "."; + host = NULL; unix_socket = vars[4].optval; } dbname = vars[1].optval; Reproduce code: --------------- <?php $dbh = new PDO("mysql:host=localhost;dbname=mysql",'user','password'); echo "Succeeded."; ?> Expected result: ---------------- The code should successfully connect to the database and print "Succeeded." Actual result: -------------- Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2005] Unknown MySQL server host '.' (1)' in /Users/kevin/test.php:2 Stack trace: #0 /Users/kevin/foo.php(2): PDO->__construct('mysql:host=loca...', 'user', 'password') #1 {main} thrown in /Users/kevin/test.php on line 2