How can I fix the error: unable to connect to DSN 'DBI:MariaDB:database=danami_warden;host=localhost'?

You see errors like this in the mail log:

Jan 1 03:30:45 busy-gates amavis[18902]: (18902-01) (!)connect_to_sql: unable to connect to DSN 'DBI:MariaDB:database=danami_warden;host=localhost': Can't connect to local server through socket '/var/lib/mysql/mysql.sock' (13) Jan 1 03:30:45 busy-gates amavis[18902]: (18902-01) (!!)TROUBLE in check_mail: gen_mail_id FAILED: connect_to_sql: unable to connect to any dataset at (eval 100) line 253.

1. SELinux Issues

This can be caused by SELinux issues with rpm based systems using MariaDB 10.5+ with SELinux enabled. There is a bug in MariaDB where it is not setting the correct SELinux context on the MariDB socket so nothing can connect to it (MDEV-24941 bug report). To fix the issue:

Run the following commands:

semanage fcontext -a -t mysqld_exec_t -s system_u "/usr/sbin/mariadbd"
restorecon -v /usr/sbin/mariadbd
systemctl restart mariadb

This should fix the issue until MariaDB fixes their RPM packages.

2. Corrupted DB Credential Issues

This can also be caused by a missing or corrupted DB credentials in the Warden config. Admins can reset the credentials using the instructions below:

// reset the Amavis database credentials
warden --task=contentfilter:contentfilter --default=yes --reload=yes

// reset the SpamAssassin learning database credentials
warden --task=antispam:learning --default=yes --reload

 

  • selinux, socket
  • 0 Пользователи нашли это полезным
Помог ли вам данный ответ?

Связанные статьи

How can I fix any statistics generation problems?

Missing the Warden Crontab Entry There is a crontab entry that will update Warden statistics...

How can I fix the error: "milter-reject: END-OF-MESSAGE from..." in the log and found the AV in error (cannot read /etc/clam.d/scan.conf).

Cloudlinux / Imunify360 added their own version of ClamAV to their repo which accidentally...

How can I fix the error: Can't connect to TCP port 10024 on 127.0.0.0 [Address already in use] when trying to start Amavis?

When trying to start Amavis you see this in the mail log: Oct 02 03:20:15 condor3648 systemd[1]:...

How can I fix the error: Can't connect to TCP port 10024 on ::1 [Cannot assign requested address] when trying to start Amavis?

When trying to start Amavis you see this in the mail log: Oct 02 03:20:15 condor3648 systemd[1]:...

How can I fix the error: Error [Contentfilter_Settings_Contentfilter]. Message [[QUARANTINEDIR] must be a valid directory?

This error means that Amavis was not installed correctly. Try running the Warden from the command...