View Single Post
Old 11th November 2009, 10:51
dipps dipps is offline
Junior Member
Join Date: Nov 2009
Location: A small country town
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting somewhere

Hi guys, I was having a similar problem: after learning a lot of things I got past it, so thought I'd share. This site has helped me in the past.
Nov 10 18:53:06 server2 postfix/trivial-rewrite[8681]: warning: connect to mysql server Lost connection to MySQL server at 'reading initial communication packet', system error: 0
Nov 10 18:53:06 server2 postfix/trivial-rewrite[8681]: fatal: mysql:/etc/postfix/mysql/,lock|fold_fix): table lookup problem
First thing I did was to check that the mysql queries worked from command line. I did that with postmap -q and mysql (logging onto mysql as the postfix user, same as postfix will do). This worked fine. I had a good look at it with phpmyadmin and the info seemed to be there, but still, trivial-rewrite couldn't do mysql lookups.

I read that "hosts localhost" and "hosts" worked differently in mysql, so tried both those in the query. Didn't make any difference. I tried making a connection to the socket instead... "hosts unix:/var/run/mysqld/mysqld.sock" and that failed too.

(For the record: connect to mysql on localhost, and the client makes a unix domain, socket connection, NOT a network connection. If you connect to then it does networking. And I thought localhost and meant the same thing )

I edited /etc/postfix/ so it would NOT chroot trivial-rewrite. Amazingly... postfix did its first mysql lookup, using hosts unix:

But I wanted to put trivial-rewrite back in its chroot, so wanted the network connection to About this time, I found that even command-line connections to failed:
# mysql --host= -u root -p
(connection refused)
So it wasn't just postfix having trouble. "netstat -nap" showed mysql listening on, as wanted. I turned on mysql's logging, and could see that it wasn't getting any requests: just sitting there idle while postfix, mysql client etc asked stuff and were refused.

I revisited the privileges tables in mysql - made sure that the postfix user could connect from host I'm not sure I did that exactly right so I won't post the details yet. Still mysql lookups failed at

I had already checked that iptables firewall was allowing access to port 3306.

About this time, a google result sent me to read README.Debian. (A bit embarrassing that I hadn't already, but there ya go.) The actual file on Lenny was /usr/share/doc/mysql-server-5.0/README.Debian.gz and it gave me the puzzle piece I needed:
If your connection is aborted immediately see if "mysqld: all" or similar is in /etc/hosts.allow and read hosts_access(5).
Sigh... I added mysqld: to hosts.allow and it all came good. The mail.log started complaining about the SQL syntax, which was really good news at the time, that was something I could fix!

I'm not finished yet still have things to fix on this postfix/mysql/etc mailserver, but this was a step forwards. Hope it helps someone.
Reply With Quote