Dovecot mysql error

Discussion in 'Installation/Configuration' started by Poliman, Nov 28, 2018.

  1. Poliman

    Poliman Member

    I have Perfect Server setup based on Ubuntu 16.04 LTS. Sometimes I have in error log:
    Code:
    Nov 27 20:25:32 s1 dovecot: auth-worker(1396): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - waiting for 1 seconds before retry
    Nov 27 20:25:32 s1 dovecot: auth-worker(1396): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - waiting for 1 seconds before retry
    Nov 27 20:25:33 s1 dovecot: auth-worker(1396): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - waiting for 5 seconds before retry
    Nov 27 20:25:33 s1 dovecot: auth-worker(1396): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - waiting for 5 seconds before retry
    
    What can I check to resolve this?
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Check the database is running.
    Code:
    systemctl status mysql.service
    systemctl --state=failed
    Check what database host, user and password dovecot uses, and verify you can connect to database with those (use mysql from command line, for example).
     
  3. Poliman

    Poliman Member

    It looks like it is running:
    Code:
    [email protected]:/var# systemctl status mysql.service
    ● mysql.service - MySQL Community Server
       Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
       Active: active (running) since Thu 2018-11-29 08:55:13 CET; 53min ago
      Process: 1318 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
      Process: 1250 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
     Main PID: 1317 (mysqld)
        Tasks: 70
       Memory: 832.5M
          CPU: 10min 7.405s
       CGroup: /system.slice/mysql.service
               └─1317 /usr/sbin/mysqld
    
    Nov 29 08:55:10 s1 systemd[1]: Starting MySQL Community Server...
    Nov 29 08:55:13 s1 systemd[1]: Started MySQL Community Server.
    
    and result of second command - also ok:
    Code:
    [email protected]:/var# systemctl --state=failed
    0 loaded units listed.
     
  4. Hello,
    Was it sporadic or are these errors often in log ?
     
  5. Poliman

    Poliman Member

    They are sporadic.
     
  6. FirstSoul

    FirstSoul New Member

    Hi,

    i have the same error.

    Code:
    Jul 22 12:42:16 web dovecot: auth-worker(2956): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - waiting for 1 seconds before retry
    Jul 22 12:42:16 web dovecot: auth-worker(2956): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - waiting for 1 seconds before retry
    Jul 22 12:42:17 web dovecot: auth-worker(2956): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - waiting for 5 seconds before retry
    Jul 22 12:42:17 web dovecot: auth-worker(2956): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - waiting for 5 seconds before retry
    Jul 22 12:42:22 web dovecot: auth-worker(2956): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - waiting for 25 seconds before retry
    Jul 22 12:42:22 web dovecot: auth-worker(2956): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) - waiting for 25 seconds before retry
    result of systemctl status mysql.service:
    Code:
     mariadb.service - MariaDB 10.1.40 database server
       Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
       Active: active (running) since Mon 2019-07-22 12:42:23 CEST; 42min ago
         Docs: man:mysqld(8)
               https://mariadb.com/kb/en/library/systemd/
      Process: 14563 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
      Process: 14560 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
      Process: 14444 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (c
      Process: 14441 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
      Process: 14422 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
     Main PID: 14532 (mysqld)
       Status: "Taking your SQL requests now..."
        Tasks: 42 (limit: 4915)
       CGroup: /system.slice/mariadb.service
               └─14532 /usr/sbin/mysqld
    
    Jul 22 12:42:21 web systemd[1]: Starting MariaDB 10.1.40 database server...
    Jul 22 12:42:22 web mysqld[14532]: 2019-07-22 12:42:22 140223953345664 [Note] /usr/sbin/mysqld (mysqld 10.1.40-MariaDB-0ubuntu0.18.04.1) starting as process 14532 ...
    Jul 22 12:42:23 web /etc/mysql/debian-start[14566]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
    Jul 22 12:42:23 web /etc/mysql/debian-start[14566]: Looking for 'mysql' as: /usr/bin/mysql
    Jul 22 12:42:23 web /etc/mysql/debian-start[14566]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
    Jul 22 12:42:23 web /etc/mysql/debian-start[14566]: This installation of MySQL is already upgraded to 10.1.40-MariaDB, use --force if you still need to run mysql_upgrade
    Jul 22 12:42:23 web systemd[1]: Started MariaDB 10.1.40 database server.
    
    result of systemctl --state=failed
    Code:
    0 loaded units listed.
    cat nano /etc/dovecot/dovecot-sql.conf
    Code:
    driver = mysql
    connect = host=localhost dbname=dbispconfig user=ispconfig password=XXXXXXXXXXXXXXXXXXXXXXX
    port=3306
    default_pass_scheme = CRYPT
    
    # password-query with prefetch
    password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_u$
    user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') $
    
    # The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
    # Do not enable it on Dovecot 1.x servers
    iterate_query = SELECT email as user FROM mail_user WHERE server_id = '1'
    Login over mysql console works with the user dbispconfig and the censored password. i can list the tables and user etc.

    any solutions?
     
    budgierless likes this.
  7. budgierless

    budgierless Member HowtoForge Supporter

    I have same issue, still trying to find a fix
     
  8. Jesse Norell

    Jesse Norell Well-Known Member

    any errors in dmesg output or to syslog or mysql log files? anything else having a problem connecting to mysql at that exact time? my first (and currently only) thought is maybe you're running into a resource limit, like number of file handles (eg. mysqld has 435 open file handles on a mail server here - it would have more if doing websites, dns, the control panel, etc., or even simply had more active users).
     
  9. ahrasis

    ahrasis Well-Known Member

  10. till

    till Super Moderator Staff Member ISPConfig Developer

Share This Page