This is driving me nuts! I am getting the classic "Can't connect to local MySQL server through socket '/var/run/mysql4d/mysql4d.sock' (13)".
Everything I've dug up so far tells me my setup should be OK (eg, defining the sockets in php.ini and my.cnf, etc). Worse... phpmyadmin works with the same un/pw I am using in my own php. So obviously it's possible to connect, but I am screwing it up
I tried reverse-engineering the connection from phpmyadmin, but gave up it as too convoluted after a couple hours.
Can anyone offer some advice?
My configuration: Ubuntu 9.10 (Karmic), Apache 2.2, PHP 5.2.6, MySQL 4.1.22 (for legacy app reasons).
my.cnf (/var/lib/mysql4/my.cnf):
[client]
port = 3306
socket = /var/run/mysql4d/mysql4d.sock
[mysqld]
port = 3306
socket = /var/run/mysql4d/mysql4d.sock
php.ini (/etc/php5/apache2/php.ini):
[MySQL]
mysql.default_socket = /var/run/mysql4d/mysql4d.sock
[MySQLi]
mysql.default_socket = /var/run/mysql4d/mysql4d.sock
Same problem using mysql instead of mysqli, btw.
EDIT: I should mention that I have installed mysql4 alongside the ubuntu default install of php & mysql for use with a legacy application and it is this installation that I am having trouble connecting with. I tried this:
ini_set('mysql.default_socket', '/var/run/mysql4d/mysql4d.sock');
and now the connection goes thru, but all queries return empty sets. (cries in frustration)