Install iRedMail with a remote MySQL server


This article describes how to install iRedMail (iRedMail-0.8.6 or later releases) with a remote MySQL server, and you must choose MySQL backend in iRedMail installation wizard.

We use below server IP addresses in our example:

iRedMail won't install MySQL server (RPM/DEB package) on localhost with remote MySQL server, but MySQL client tools are still required for remote connection.


In our case, remote MySQL server runs on server It must accept remote connection from iRedMail server BEFORE installing iRedMail, and we must create a new SQL user with password and proper privileges for remote login from iRedMail server ( in our case).

# netstat -ntlp | grep 3306
tcp        0      0  *               LISTEN      2479/mysqld

If MySQL server is listening on only, you should comment out bind-address parameter in MySQL config file my.cnf to make it listen on all available network interfaces, and restart MySQL service.

#bind-address =
mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin_iredmail'@'' IDENTIFIED BY 'admin_password' WITH GRANT OPTION;

With above commands, MySQL user admin_iredmail is allowed to connect from IP address with password admin_password.


If you tried to install iRedMail with this remote MySQL server before, please backup existing databases on remote MySQL server first, then drop them and delete related MySQL users, because they will be created by iRedMail automatically on remote MySQL server:

mysql> DROP DATABASE amavisd;
mysql> DROP DATABASE cluebringer;
mysql> DROP DATABASE iredadmin;
mysql> DROP DATABASE roundcubemail;
mysql> DROP DATABASE sogo;
mysql> DROP DATABASE vmail;

mysql> DROP USER 'amavisd'@'';
mysql> DROP USER 'cluebringer'@'';
mysql> DROP USER 'iredadmin'@'';
mysql> DROP USER 'roundcube'@'';
mysql> DROP USER 'sogo'@'';
mysql> DROP USER 'vmail'@'';
mysql> DROP USER 'vmailadmin'@'';

Install iRedMail

Please follow iRedMail installation guide strictly, but start iRedMail installer with below command instead of the original one (bash



It will launch iRedMail installation wizard as usual.

Parameters we used in above command line:

iRedMail will create new SQL users for applications like Postfix, Amavisd, Roundcube webmail, etc, and grant proper privileges to them which will connect from iRedMail server.

One more optional parameter is MYSQL_SERVER_PORT. it specifies listen port of remote MySQL server. Default one is 3306, you can change it if remote MySQL server is running on a different port.

After iRedMail installation

As mentioned above, it's now ok to delete the new MySQL user admin_iredmail on remote MySQL server. It will not be used anymore.

mysql> DROP USER 'admin_iredmail'@'';