V
V
Vyacheslav Kordienko2017-01-20 09:48:15
linux
Vyacheslav Kordienko, 2017-01-20 09:48:15

"Can't connect to local MySQL..." error (Postfix+Dovecot)?

Hello everyone,
I'm setting up Postfix, users will be stored in the MySQL database.
When checking via telnet, at the step

# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 mail.site.ru ESMTP
HELO site.ru
250 mail.site.ru
MAIL FROM: [email protected]

timeout without response
in var/log/maillog logs, such an error
Jan 19 18:07:54 site postfix/trivial-rewrite[21988]: fatal: mysql:/etc/postfix/sql/valias.cf(0,lock|fold_fix): table lookup problem
Jan 19 18:07:55 site postfix/smtpd[21791]: warning: problem talking to service rewrite: Success
Jan 19 18:07:55 site postfix/smtpd[21903]: warning: problem talking to service rewrite: Connection reset by peer
...
Jan 19 23:09:18 site postfix/master[21786]: warning: process /usr/libexec/postfix/smtpd pid 23034 exit status 1
Jan 19 23:09:18 site postfix/master[21786]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling
Jan 19 23:10:00 site postfix/trivial-rewrite[26149]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Jan 19 23:10:00 site postfix/trivial-rewrite[26149]: fatal: mysql:/etc/postfix/sql/valias.cf(0,lock|fold_fix): table lookup problem
Jan 19 23:10:01 site postfix/master[21786]: warning: process /usr/libexec/postfix/trivial-rewrite pid 26149 exit status 1
Jan 19 23:10:01 site postfix/master[21786]: warning: /usr/libexec/postfix/trivial-rewrite: bad command startup -- throttling

I can't figure out what's the problem
spoiler
soft_bounce = no
queue_directory = /var/spool/postfix
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
default_privs = nobody
inet_interfaces = all

myhostname = mail.site.ru 
mydomain = site.ru
myorigin = $mydomain

mydestination = $myhostname,localhost.$myhostname,localhost
local_recipient_maps = proxy:unix:passwd.byname $alias_maps
unknown_local_recipient_reject_code = 550
mynetworks = 127.0.0.0/8
relay_domains =
#alias_maps = hash:/etc/aliases
#alias_database = hash:/etc/aliases
mail_spool_directory = /var/mail
smtpd_banner = $myhostname ESMTP

debug_peer_level = 2
debug_peer_list = 127.0.0.1
debugger_command = 
    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
    xxgdb $daemon_directory/$process_name $process_id & sleep 5 
sendmail_path = /usr/sbin/sendmail
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/local/man
config_directory = /etc/postfix

virtual_mailbox_domains = mysql:$config_directory/sql/vdomains.cf
virtual_mailbox_base = /var/vmail
virtual_mailbox_maps = mysql:$config_directory/sql/vmailbox.cf
virtual_alias_maps = mysql:$config_directory/sql/valias.cf
virtual_minimum_uid = 1150
virtual_uid_maps = static:1150
virtual_gid_maps = static:12
virtual_transport = dovecot

dovecot_destination_recipient_limit = 1

smtpd_sasl_auth_enable = yes
smtpd_sasl_exceptions_networks = $mynetworks
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = /var/spool/postfix/private/dovecot-auth

smtpd_use_tls = yes
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtp_tls_session_cache_database = btree:$data_directory/smtp_tls_session_cache
smtpd_tls_key_file = /etc/postfix/certs/key.pem
smtpd_tls_cert_file = /etc/postfix/certs/cert.pem
tls_random_source = dev:/dev/urandom

smtpd_recipient_restrictions = permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination,
    reject_non_fqdn_recipient,
    reject_invalid_hostname,
    reject_unknown_recipient_domain,
    reject_unknown_client,
    reject_unlisted_recipient,
    reject_unverified_recipient,
    reject_unauth_pipelining,
    reject_rbl_client cbl.abuseat.org,
    reject_rbl_client dialups.mail-abuse.org,
    reject_rbl_client bl.spamcop.net,
    reject_rbl_client zen.spamhaus.org,
    reject_rbl_client sbl-xbl.spamhaus.org,
    permit

smtpd_client_restrictions =
    reject_unauth_pipelining,
    permit_sasl_authenticated,
    permit_mynetworks,
    reject_unknown_client_hostname,
    permit
smtpd_helo_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_invalid_hostname,
    reject_invalid_helo_hostname,
    reject_unknown_hostname,
    reject_non_fqdn_helo_hostname,
    reject_unknown_helo_hostname,
    permit
smtpd_sender_restrictions =
    permit_sasl_authenticated,
    permit_mynetworks,
    reject_non_fqdn_sender,
    reject_authenticated_sender_login_mismatch,
    reject_unauthenticated_sender_login_mismatch,
    reject_unknown_sender_domain,
    permit_sasl_authenticated,
    reject_sender_login_mismatch
    permit

#ClamAV
content_filter = scan:127.0.0.1:10025
receive_override_options = no_address_mappings

#DKIM
milter_default_action = accept
milter_protocol = 2
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2017-01-20
@AmonTobin

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Is MySQL installed on the computer? Launched? Are there any errors in the MySQL logs? Postfix user created?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question