Mysql – Postfix error: warning thesql: /etc/postfix/maps/alias.cf lookup error

MySQLpostfix

Yesterday I set up a mail server following this tutorial and everything worked fine, but today I am unable to send or receive mails.
When I want to send a mail with my support@example.com from Thunderbird it asks for my password then it doesn't accept it (I checked 3 different mail addresses).

postfix/pickup[15575]: 8724D2C411F5: uid=33 from=<www-data>
postfix/cleanup[16104]: 8724D2C411F5: message-id=<20130715165704.8724D2C411F5@Ubuntu-1204-precise-64-minimal.localdomain>
postfix/cleanup[16104]: warning: connect to mysql server 127.0.0.1: Can't connect to MySQL server on '127.0.0.1' (111)
warning  mysql: /etc/postfix/maps/alias.cf lookup error for "myname@gmail.com"
warning: A3C912C411F5: virtual_alias_maps map lookup problem for "myname@gmail.com" -- deferring delivery

This myname@gmail.com is my personal address.

ls -la /etc/postfix
drwxr-xr-x   4 root root  4096 Jul 14 11:06 .
drwxr-xr-x 124 root root 12288 Jul 14 22:51 ..
-rw-r--r--   1 root root   329 Jul 14 09:50 dynamicmaps.cf
-rw-r--r--   1 root root  1651 Jul 14 10:49 main.cf
-rw-r--r--   1 root root  1286 Jul 14 09:50 main.cf.default
drwxr-xr-x   2 root root  4096 Jul 15 18:42 maps
-rw-r--r--   1 root root  4798 Jul 14 09:57 master.cf
-rw-r--r--   1 root root  5531 Jul 14 09:50 master.cf.default
-rw-r--r--   1 root root 19707 Feb 20 21:03 postfix-files
-rwxr-xr-x   1 root root  8729 Feb 20 21:03 postfix-script
-rwxr-xr-x   1 root root 26498 Feb 20 21:03 post-install
drwxr-xr-x   2 root root  4096 Jul 14 10:07 sasl


ls -la /etc/postfix/maps
total 20
drwxr-xr-x 2 root    root    4096 Jul 15 18:42 .
drwxr-xr-x 4 root    root    4096 Jul 14 11:06 ..
-rwx------ 1 postfix postfix  158 Jul 15 18:42 alias.cf
-rwx------ 1 postfix postfix  170 Jul 14 10:05 domain.cf
-rwx------ 1 postfix postfix  235 Jul 14 10:05 user.cf

In MYSQL:

SHOW GRANTS FOR root@%
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION

When I set in /etc/mysql/my.cnf the bind-address to 127.0.0.1 I can send and receive emails but I cannot open my website:

ERROR: SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'mywebsite.com' (111)

If I change it back to the IP address of the website, the website loads but then I cannot send or receive emails.

In /etc/hosts I have

my.ip.address www.example.com Ubuntu-1204-precise-64-minimal

If I comment out the bind-address parameter everything is working fine but I think that parameter is there for a reason. Any ideas?

Best Answer

When you comment out the bind parameter mysql will bind to all interfaces. This leaves your mysql server exposed to the internet so If you need to have mysql listening on the internet facing interface because another remote server needs to use it then you can use iptables or hosts.allow to filter traffic to limit your attack surface.