Friday, August 3, 2012

Proftpd: Can't connect to local MySQL server through socket

When using proftpd daemon with logging or authenticating with mysql database I've got following message in SQLLogFile:
error: '2002'
mod_sql/4.2.5[1245]: message: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'


This error caused inability to download file from ftp share.
To resolve this issue check the mysqld.sock path and set right address to connect to your DB in proftpd.conf.

You can find the right address in my.cnf configuration file under bind-address parameter.

Example:
cat /etc/mysql/my.cnf | grep bind-address
bind-address            = 127.0.0.1

cat /etc/proftpd.conf | grep -i sqlconnectinfo
SQLConnectInfo    mydatabase@127.0.0.1 mysqluser password