title: Postfix + Dovecot Connect failed to database
body: <p>I have installed a new Mailserver based on Postfix and Dovecot.
  The setup were fine while I configurated everything. No error outputs or someting.</p>
  
  <p><strong>The problem is:</strong>
  When i try to connect to a mail account over a client, its going to idle at the authentication. </p>
  
  <p>Inside the /var/log/mail.log</p>
  
  <pre><code>dovecot: auth-worker(15467): Error: mysql(localhost): Connect failed to database (mail): Access denied for user 'mail'@'localhost' (using password: YES) - waiting for 1 seconds before retry
  </code></pre>
  
  <p>So, i would say Dovecot cant connect to the database / wont auth.
  But i have no idea why.
  The database user has the right privileges for that database / also tried to flush the privileges.
  I read that sometimes the auth failed because of the encrypt algo.
  So i set the mail user password with the <code>OLD_PASSWORD</code> function (found that <a href="http://blog.lenss.nl/2009/06/postfix_dovecot_mysql_access_denied/" rel="nofollow">here</a>). Also wont work.</p>
  
  <p>Here is my driver conf (dovecot-mysql.conf)</p>
  
  <pre><code>driver = mysql
  connect = host=localhost dbname=mail user=mail password='mypassword'
  default_pass_scheme = PLAIN-MD5
  password_query = SELECT password FROM mailbox WHERE username = '%u'
  user_query = SELECT CONCAT('maildir:/var/vmail/',maildir) AS mail, 6000 AS uid, 6000 AS gid FROM mailbox WHERE username = '%u'
  </code></pre>
  
  <p><em>(mypassword is changed here)</em></p>
  
  <p>So i dont know why it wont give me the access to the database.
  Someone any idea?</p>
  
  <p><strong>I would be grateful for any help!</strong></p>
  
  <hr>
  
  <p>Annotation:<br>
  Server: Debian v7.9<br>
  Database: MySQL 5.6.25<br>
  Dovecot: 2.1.7<br>
  Postfix: 2.9.6<br></p>
  
  <p>postconf -n</p>
  
  <pre><code>alias_database = hash:/etc/aliases
  alias_maps = hash:/etc/aliases
  append_dot_mydomain = no
  biff = no
  broken_sasl_auth_clients = yes
  config_directory = /etc/postfix
  disable_vrfy_command = yes
  dovecot_destination_recipient_limit = 1
  inet_interfaces = all
  local_transport = virtual
  mailbox_command = procmail -a "$EXTENSION"
  mailbox_size_limit = 0
  mydestination = markheumueller.de, localhost
  myhostname = h2377359.stratoserver.net
  mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
  myorigin = /etc/mailname
  proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps
  readme_directory = no
  recipient_delimiter = +
  relayhost =
  smtp_tls_security_level = may
  smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
  smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
  smtpd_recipient_restrictions = permit_sasl_authenticated permit_mynetworks reject_unauth_destination
  smtpd_sasl_auth_enable = yes
  smtpd_sasl_authenticated_header = yes
  smtpd_sasl_path = private/auth_dovecot
  smtpd_sasl_type = dovecot
  smtpd_sender_login_maps = proxy:mysql:/etc/postfix/mysql-sender-login-maps.cf
  smtpd_sender_restrictions = reject_authenticated_sender_login_mismatch reject_unknown_sender_domain
  smtpd_tls_cert_file = /etc/postfix/ssl/mailserver.crt
  smtpd_tls_key_file = /etc/postfix/ssl/mailserver.key
  smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
  smtpd_use_tls = yes
  virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual-alias-maps.cf
  virtual_gid_maps = static:6000
  virtual_mailbox_base = /var/vmail/
  virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual-domains-maps.cf
  virtual_mailbox_limit = 0
  virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
  virtual_minimum_uid = 104
  virtual_transport = dovecot
  virtual_uid_maps = static:6000
  </code></pre>