|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57671 PDO Doesn't obey mysql.default_socket
Submitted: 2007-05-15 15:49 UTC Modified: 2008-09-12 10:46 UTC
From: cweldon at tamu dot edu Assigned:
Status: Not a bug Package: PDO (PECL)
PHP Version: 5.2.0 OS: Mac OS X Server 10.4
Private report: No CVE-ID: None
 [2007-05-15 15:49 UTC] cweldon at tamu dot edu
When connecting to MySQL via the standard PDO DSN (shown in the reproduce code section), I get a connection error (shown in the actual result). My php.ini file has the mysql.default_socket set to '/var/mysql/mysql.sock' and I additionally have in my .htaccess file:

php_value mysql.default_socket '/var/mysql/mysql.sock'

The phpinfo() script reports:


MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => 5.0.24a
MYSQL_SOCKET => /tmp/mysql.sock
MYSQL_INCLUDE => -I/usr/local/php5/include/mysql
MYSQL_LIBS => -L/usr/local/php5/lib/mysql -lmysqlclient

Directive => Local Value => Master Value
mysql.allow_persistent => On => On
mysql.connect_timeout => 60 => 60
mysql.default_host => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
mysql.default_user => no value => no value
mysql.max_links => Unlimited => Unlimited
mysql.max_persistent => Unlimited => Unlimited
mysql.trace_mode => Off => Off

Regular MySQL access through PHP works (ie: mysql_connect(), mysql_query(), etc.), but PDO does not seem to be obeying it, and I shouldn't have to force set the dbh to look like:


since this application may float between servers where the socket is not always located here.

Reproduce code:
define('DBMS', 'mysql');
define('DBMS_HOSTNAME', 'localhost');
define('DBMS_USERNAME', 'username');
define('DBMS_PASSWORD', 'password');
define('DBMS_DATABASE', 'database');


Expected result:
The database connection should succeed and execute the code appropriately. 

Actual result:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)' in /Library/WebServer/Documents/devel/Classes/dbNew.class.php:26 Stack trace: #0 /Library/WebServer/Documents/devel/Classes/dbNew.class.php(26): PDO->__construct('mysql:host=loca...', 'username', 'password', Array) #1 /Library/WebServer/Documents/devel/Classes/Customer.class.php(4): require_once('/Library/WebSer...') #2 /Library/WebServer/Documents/devel/Admin/transactionView.php(22): require_once('/Library/WebSer...') #3 {main} thrown in /Library/WebServer/Documents/devel/Classes/dbNew.class.php on line 26


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-15 15:57 UTC] cweldon at tamu dot edu
 [2008-09-12 10:46 UTC] johannes at schlueters dot de
mysql.* ini settings are from ext/mysql, not pdo_mysql, they shouldn't affect PDO.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Aug 14 21:01:24 2020 UTC