When trying to run Postfix with virtual maps in MySQL, you can get the following error:
connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' postfix
This error is because postfix is running in chroot /var/spool/postfix. So it cannot find the unix socket for MySQL.
If you have the option to run mysql on 127.0.0.1 or on another IP, simply go to;
grep localhost *
and replace all localhost to 127.0.0.1 or the IP in all files starting with mysql-virtual.
If you insist on running via unix sockets, you can simply fix it by running;
mount –bind /var /var/spool/postfix/var
Ater this, all will work fine.