This answer is likely to drown here, but maybe somebody stumbles upon it accidentally.
In my case, SELinux prevented the user/application from connecting to the MySQL (MariaDB) server socket. On RHEL, check /var/log/audit/audit.log
if you have SELinux enabled.