1

Topic: Errors on fresh install

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): latest
- Deployed with the downloadable installer
- Linux/BSD distribution name and version: Ubuntu 20.04 LTS
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): nginx
====

I got another issue on fresh Ubuntu 20.04 system
Every Saturday at 06:02 i receive these 2 emails:

From:

Cron <root@mail> /bin/bash /usr/local/bin/fail2ban_banned_db unban_db

Message:

ERROR 2002 (HY000): Can't connect to MySQL server on '127.0.0.1' (115)

and

From:

Cron <root@mail> python3 /opt/iredapd/tools/spf_to_greylist_whitelists.py >/dev/null

Message:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 581, in connect
    sock = socket.create_connection(
  File "/usr/lib/python3.8/socket.py", line 808, in create_connection
    raise err
  File "/usr/lib/python3.8/socket.py", line 796, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/iredapd/tools/spf_to_greylist_whitelists.py", line 91, in <module>
    qr = conn.select('greylisting_whitelist_domains', what='domain')
  File "/usr/local/lib/python3.8/dist-packages/web/db.py", line 890, in select
    return self.query(qout, processed=True)
  File "/usr/local/lib/python3.8/dist-packages/web/db.py", line 836, in query
    db_cursor = self._db_cursor()
  File "/usr/local/lib/python3.8/dist-packages/web/db.py", line 743, in _db_cursor
    return self.ctx.db.cursor()
  File "/usr/local/lib/python3.8/dist-packages/web/db.py", line 683, in _getctx
    self._load_context(self._ctx)
  File "/usr/local/lib/python3.8/dist-packages/web/db.py", line 695, in _load_context
    ctx.db = self._connect(self.keywords)
  File "/usr/local/lib/python3.8/dist-packages/web/db.py", line 723, in _connect
    return self.db_module.connect(**keywords)
  File "/usr/lib/python3/dist-packages/pymysql/__init__.py", line 94, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 325, in __init__
    self.connect()
  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 630, in connect
    raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' ([Errno 111] Connection refused)")

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Errors on fresh install

Have you checked if MySQL is running? It looks like it might be dying (oom-killer, maybe?).

3

Re: Errors on fresh install

systemctl status mysql says:

mariadb.service - MariaDB 10.3.25 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/mariadb.service.d
             └─override.conf
     Active: active (running) since Sat 2021-02-27 03:02:28 UTC; 2 days ago
       Docs: man:mysqld(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 754 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 808 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 826 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
    Process: 1189 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 1191 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 953 (mysqld)
     Status: "Taking your SQL requests now..."
      Tasks: 34 (limit: 4577)
     Memory: 141.5M
     CGroup: /system.slice/mariadb.service
             └─953 /usr/sbin/mysqld

Feb 27 03:02:19 mail mysqld[953]: 2021-02-27  3:02:19 0 [Note] /usr/sbin/mysqld (mysqld 10.3.25-MariaDB-0ubuntu0.20.04.1) starting as process 953 ...
Feb 27 03:02:28 mail systemd[1]: Started MariaDB 10.3.25 database server.
Feb 27 03:02:28 mail /etc/mysql/debian-start[1195]: Upgrading MySQL tables if necessary.
Feb 27 03:02:31 mail /etc/mysql/debian-start[1198]: Looking for 'mysql' as: /usr/bin/mysql
Feb 27 03:02:31 mail /etc/mysql/debian-start[1198]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Feb 27 03:02:31 mail /etc/mysql/debian-start[1198]: Version check failed. Got the following error when calling the 'mysql' command line client
Feb 27 03:02:31 mail /etc/mysql/debian-start[1198]: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Feb 27 03:02:31 mail /etc/mysql/debian-start[1198]: FATAL ERROR: Upgrade failed
Feb 27 03:02:31 mail /etc/mysql/debian-start[1302]: Checking for insecure root accounts.
Feb 27 03:02:31 mail debian-start[1307]: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Well this is a fresh install with no domains/users added. Does system connect to mysql only once per week?

4 (edited by Fastidious 2021-03-01 20:50:59)

Re: Errors on fresh install

I don’t know how you installed, what answers you provided during the install, or what could have happened. The errors I see seems to point to the MariaDB root user not having a password set, or it being wrong.

Connect to your MariaDB server from the command line (mysql -u root) and let us know if you can login. After you login (assuming you successfully can), try this:

MariaDB [(none)]> USE mysql;
MariaDB [mysql]> UPDATE user SET plugin='unix_socket' WHERE User='root';
MariaDB [mysql]> quit

Then reboot and check for errors again.

5 (edited by Fastidious 2021-03-01 21:21:08)

Re: Errors on fresh install

I installed iRedmail yesterday, on a fresh VPS, so I took a look around. I am not getting the emails errors you are getting, but see a related error on MariaDB, similar to yours:

Mar 01 07:56:02 mail.example.com mysqld[26697]: 2021-03-01  7:56:02 0 [Note] /usr/sbin/mysqld (mysqld 10.3.25-MariaDB-0ubuntu0.20.04.1) starting as process 26697 ...
Mar 01 07:56:02 mail.example.com systemd[1]: Started MariaDB 10.3.25 database server.
Mar 01 07:56:02 mail.example.com /etc/mysql/debian-start[26733]: Upgrading MySQL tables if necessary.
Mar 01 07:56:02 mail.example.com /etc/mysql/debian-start[26736]: Looking for 'mysql' as: /usr/bin/mysql
Mar 01 07:56:02 mail.example.com /etc/mysql/debian-start[26736]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Mar 01 07:56:02 mail.example.com /etc/mysql/debian-start[26736]: Version check failed. Got the following error when calling the 'mysql' command line client
Mar 01 07:56:02 mail.example.com /etc/mysql/debian-start[26736]: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Mar 01 07:56:02 mail.example.com /etc/mysql/debian-start[26736]: FATAL ERROR: Upgrade failed
Mar 01 07:56:02 mail.example.com /etc/mysql/debian-start[26746]: Checking for insecure root accounts.
Mar 01 07:56:02 mail.example.com debian-start[26749]: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

While checking the status on MariaDB. Digging around to see what it could be. Maybe ZhangHuangbin can shed some light.

6

Re: Errors on fresh install

I also noticed that `/etc/mysql/debian.cnf` has empty password lines:

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = root
password =
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = root
password =
socket   = /var/run/mysqld/mysqld.sock

7

Re: Errors on fresh install

OK, this fixed the problem:

MariaDB [(none)]> USE mysql;
MariaDB [mysql]> UPDATE user SET plugin='unix_socket' WHERE User='root';
MariaDB [mysql]> quit

8

Re: Errors on fresh install

Also for me, Ubuntu 20.04 LTS fresh install.

Running into same error in log.
I'll wait for Mr. Zhang, to test any response should come out.

9

Re: Errors on fresh install

Is mysql service running on 127.0.0.1? Please show us command output:

netstat -ntlp | grep 3306

10 (edited by dave.opc 2021-03-03 16:23:25)

Re: Errors on fresh install

I have already fixed the issue with command in mysql database provided by Fastidious above.
But i think something should be fixed in install scripts for Ubuntu 20.04.
So my netstat -ntlp | grep 3306

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      928/mysqld