Please try again with below steps:
*) Make sure you can connect to remote MySQL server from iRedMail server before installing.
*) Please make sure iRedMail server can login to remote MySQL server with proper privileges. A simple way is granting all privileges with below command (on remote MySQL server):
mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin_on_iredmail'@'[ip_of_iredmail_server]' IDENTIFIED BY '[admin_password]' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
IMPORTANT NOTE: 'WITH GRANT OPTION' in above SQL command is required.
NOTES:
* You can use 'root' as remote MySQL user name which will be used on iRedMail server side during iRedMail installation, or a custom user name. for example, 'admin_on_iredmail', etc. A custom user name should be better to help you understand what it's used for, and less confuse with default 'root' user.
* You must replace '[ip_of_iredmail_server]' by the real IP address of your iRedMail server in above command. For example,
… TO 'admin_on_iredmail'@'172.31.4.xx' …
* It's OK to delete this user after iRedMail installation.
*) Find below lines in file 'conf/global' in iRedMail before installation:
# File: conf/global
# MySQL server
export MYSQL_SERVER="${LOCAL_ADDRESS}"
export MYSQL_SERVER_PORT='3306'
export MYSQL_ROOT_USER='root'
Change the MySQL server address (MYSQL_SERVER) to your remote MySQL server, and update port number (MYSQL_SERVER_PORT) and root user name (MYSQL_ROOT_USER) if needed. MYSQL_ROOT_USER must be the same as mentioned in above step (admin_on_iredmail). Save your changes.
*) Find below line in file 'conf/global' in iRedMail before installation:
# File: conf/global
if [ X"${LOCAL_ADDRESS}" == X'127.0.0.1' ]; then
export SQL_HOSTNAME='localhost'
Replace 'localhost' by the IP address of your iRedMail server (WARNING: not IP address of your remote MySQL server). Save your changes.
*) Start iRedMail installation, when it prompts to input MySQL root password, enter the correct one (password for your remote MySQL server).
That's all. If it doesn't work for you, please do let us know, so that we can improve it.