-- Create database for virtual hosts
CREATE DATABASE IF NOT EXISTS PH_VMAIL_DB_NAME CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

-- Create user.
CREATE USER 'PH_VMAIL_DB_BIND_USER'@'PH_MYSQL_GRANT_HOST'
    IDENTIFIED BY 'PH_VMAIL_DB_BIND_PASSWD';

CREATE USER 'PH_VMAIL_DB_ADMIN_USER'@'PH_MYSQL_GRANT_HOST'
    IDENTIFIED BY 'PH_VMAIL_DB_ADMIN_PASSWD';

-- Grant Permissions
GRANT SELECT
    ON PH_VMAIL_DB_NAME.*
    TO 'PH_VMAIL_DB_BIND_USER'@'PH_MYSQL_GRANT_HOST';

GRANT SELECT,INSERT,DELETE,UPDATE
    ON PH_VMAIL_DB_NAME.*
    TO 'PH_VMAIL_DB_ADMIN_USER'@'PH_MYSQL_GRANT_HOST';

FLUSH PRIVILEGES;
