I am trying to make my own mail service using Postfix, but I run into an issue in the setup phase, and it's that postfix can't connect to the database. Here's what the error log says:
⛔Database connection string : mysql:host=localhost;dbname=postfixadmindb;charset=UTF8
⛔Problem connecting to database, check database configuration ($CONF['database_*'] entries in config.local.php)
⛔SQLSTATE[HY000] [2002] Permission denied
Here's the config file:
<?php
$CONF['database_type'] = 'mysqli';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfixuser';
$CONF['database_password'] = 'XXXXXXXX';
$CONF['database_name'] = 'postfixadmindb';
$CONF['configured'] = true;
$CONF['encrypt'] = 'md5crypt';
$CONF['setup_password'] = 'the setup password';
?>
First of all, I tried connecting to the database normally:
sudo mysql -u postfixuser -p'thecorrectpassword' -h localhost postfixadmindb
This works fine and brings me tho the MariaDB shell as expected
I then granted postfixuser all privileges in the database, but that didn't solve the issue.
I checked the log under /var/log/mysql/error.log but it's empty
I'm doing this on a WSL machine running Ubuntu 22.04.1 LTS, serving the postfixadmin web pages with apache.
sudo mysql -u postf..will run the mysql commandline client with root privileges and is an insufficient check to see if an unprivileged user can also connect to the mysql socket. Try running that again withoutsudoand if that fails there may be a file system permission problem prevent the postfix user from connecting to the database via the MariaDB socket. – HBruijn Mar 28 '23 at 13:16sudodoes indeed fail: `mysql -u postfixuser -p'XXXX' -h localhost postfixadmindb – swegbarca Mar 28 '23 at 13:35