FS#18563 - [php] 5.3.2 MySQL connection refused
Attached to Project:
Arch Linux
Opened by Toni Viemerö (skithund) - Thursday, 04 March 2010, 20:22 GMT
Last edited by Pierre Schmitz (Pierre) - Thursday, 04 March 2010, 22:40 GMT
Opened by Toni Viemerö (skithund) - Thursday, 04 March 2010, 20:22 GMT
Last edited by Pierre Schmitz (Pierre) - Thursday, 04 March 2010, 22:40 GMT
|
Details
Once again PHP upgrade broke local MySQL connections.
Missing mysql-socket-patch? Downgrading to 5.3.1-7 fixes things. |
This task depends upon
[mysqld]
socket = /var/run/mysqld/mysqld.sock
php.ini (via 'php -i'):
mysql.default_socket => /var/run/mysqld/mysqld.sock
mysqli.default_socket => /var/run/mysqld/mysqld.sock
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock
php values are empty in php.ini
$ mysql --socket=/var/run/mysqld/mysqld.sock --protocol=socket -uXX -pXX test
Welcome to the MySQL monitor.
$ mysql -hlocalhost -uXX -pXX test
Welcome to the MySQL monitor.
...and a "misconfiguration" by me, since I'm connecting using "dbhost" instead of "localhost".
"dbhost" used to be another server, but due to hardware malfunction it's running locally temporarily.
For some odd reason it's using TCP instead of sockets. Problem solved by opening 3306 from iptables.
$ sudo pacman -U php-*5.3.2*xz
[...]
$ php -r "mysql_connect('dbhost', 'XX', 'XX');"
PHP Warning: mysql_connect(): [2002] Connection refused (trying to connect via tcp://dbhost:3306) in Command line code on line 1
$ sudo pacman -U php-*5.3.1-6*gz
[...]
$ php -r "mysql_connect('dbhost', 'XX', 'XX');"
$
and especially this note:
Note: Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as Runtime Configuration in your PHP configuration and leave the server field blank.
http://bugs.archlinux.org/task/17179
http://bugs.php.net/50231
Thanks for listening :) This bug can now be closed as user error :)