Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm following the well-known tutorial, and I'm at this step

However I've got a problem when trying to run

postmap -q example.org mysql:/etc/postfix/mysql-virtual-box-domains.cf

I get:

postmap: warning: connect to mysql server 127.0.0.1: Lost connection to MySQL server at 'reading initial communication packet', system error: 0

However I am able to connect to mysqld via mysql: mysql -u mailuser -p, with the password "foo". The .cf looks like this:

user = mailuser
password = foo
hosts = 127.0.0.1
dbname = mailserver
query = SELECT 1 FROM virtual_domains WHERE name='%s'

What could be the problem?

Addendum

The relevant part from my.cf looks like this:

# The MySQL server
[mysqld]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 16K
myisam_sort_buffer_size = 8M

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
bind-address = 127.0.0.1
share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

run postmap with more verbose output and post the output here. Hopefully you get some useful information out of it.

postmap -vvvq example.org mysql:/etc/postfix/mysql-virtual-box-domains.cf
share|improve this answer
    
Thank You, fixed it by setting hosts = localhost –  Flavius A Feb 18 '10 at 18:49
add comment

mysqld can listen both to a local socket and a tcp/ip socket. By default it connects to the local socket (which is how you are connecting to it when running "mysql" on the command line). postgres is trying to connect via a tcp/ip socket on localhost and is not succeeding.

So, make mysqld listen on both interface types (or figure out why it's not if it's supposed to be), or make postgres use the local socket.

To simulate what postgres is doing from the command line BTW, you can run it like this:

mysql -u mailuser -h 127.0.0.1 -p
share|improve this answer
    
Uhm, mysqld is configured to listen on 0.0.0.0 which basically means all ifaces, right? Anyway I'll add my.cf to the question. Oh, and I see it listens on 0.0.0.0:3306 with nestat -tlnp –  Flavius A Feb 18 '10 at 17:58
    
iptables? (......) –  jj33 Feb 18 '10 at 18:07
    
no iptables, /etc/hosts.allow is: 3306 : ALL : allow –  Flavius A Feb 18 '10 at 18:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.