I'm having an issue setting the default PDO socket location for MySQL, without doing it through the initialisation of the PDO class into a variable. I've tried altering the mysql.default_socket variable. But no joy with that. The only way that works currently is through the class DSN instantiation.
php.ini Contents:
[PHP]
engine = On
zend.ze1_compatibility_mode = Off
short_open_tag = On
asp_tags = Off
precision = 14
y2k_compliance = On
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func=
serialize_precision = 100
allow_call_time_pass_reference = Off
safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
disable_functions =
disable_classes =
expose_php = Off
max_execution_time = 300
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_NOTICE
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
variables_order = "EGPCS"
register_globals = Off
register_long_arrays = Off
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root =
user_dir =
extension_dir = "/usr/lib64/php/modules"
enable_dl = On
file_uploads = On
upload_max_filesize = 500M
allow_url_fopen = On
default_socket_timeout = 60
[Syslog]
define_syslog_variables = Off
sendmail_path = /usr/sbin/sendmail -t -i
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[MySQL]
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port = 3306
mysql.default_socket = /home/mysql/mysql.sock
mysql.default_host = 127.0.0.1
mysql.default_user = conner
mysql.default_password = danica4eva
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket = /home/mysql/mysql.sock
mysqli.default_host = 127.0.0.1
mysqli.default_user = conner
mysqli.default_pw = danica4eva
mysqli.reconnect = Off
[mSQL]
msql.allow_persistent = On
msql.max_persistent = -1
msql.max_links = -1
[PostgresSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[Sybase]
sybase.allow_persistent = On
sybase.max_persistent = -1
sybase.max_links = -1
sybase.min_error_severity = 10
sybase.min_message_severity = 10
sybase.compatability_mode = Off
[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0
[Informix]
ifx.default_host =
ifx.default_user =
ifx.default_password =
ifx.allow_persistent = On
ifx.max_persistent = -1
ifx.max_links = -1
ifx.textasvarchar = 0
ifx.byteasvarchar = 0
ifx.charasvarchar = 0
ifx.blobinfile = 0.
ifx.nullformat = 0
[Session]
session.save_handler = files
session.save_path = "/var/lib/php/session"
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 1
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = Off
mssql.secure_connection = Off
[Verisign Payflow Pro]
pfpro.defaulthost = "test-payflow.verisign.com"
pfpro.defaultport = 443
pfpro.defaulttimeout = 30
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
zend_extension = /etc/ioncube/ioncube_loader_lin_5.3.so
As you can see, I have changed the default socket settings within the php.ini file, but I still get a socket error in PDO when I try to connect to MySQL. It leads me to believe that the PDO driver is not using the settings from the php.ini. I was sure that there was some way of configuring PDO, but there was nothing within my php.ini. Should there be settings for PDO within the php.ini, or are they contained elsewhere?
There is a different ini setting for the PDO mysql driver. It is called
pdo_mysql.default_socket
Have you tried to set this ini value? Please refer to http://php.net/manual/en/ref.pdo-mysql.php
The value can also being influenced during compile time using the following configure option:
--with-mysql-sock=/my/path/mysql.sock
Update: I've figured out that the problem is a known PHP bug.
First: you can workaround the problem when using 127.0.0.1 as the db host instead of localhost. PHP will connect trough a TCP socket this way.
To change the location you'll have to compile PHP from sources with special configuration options. I was successful to change the location of the mysql socket with the following (basic) command lines :
./configure \
--with-mysql \
--with-mysqli=mysqlnd \
--enable-pdo \
--with-pdo-mysql=mysqlnd \
--with-mysql-sock=/home/mysql/mysqld.sock
make
make install
The final trick made the combination of the last both of them. --with-mysql-sock=file
sets the location of the .sock file but it is just used if --with-pdo-mysql=
is set to mysqlnd
(mysql native driver). If this option is missing pdo would be linked against the libmysqlclient from the system. As a result of this you can also recompile libmysqlclient (with modified socket path) and leave php untouched.
Note: This is just the basic configuration to make PHP working with PDO. You'll need additional configuration options if you need additional extensions (like json, xml, whatever). You'll find the configuration that your Linux Distribution has used to compile PHP if you execute the (original distribution) version this way: php -i
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With