If you have only worked with MySQL locally in WAMP, this guide explains step-by-step how to get real cloud servers online and sync them automatically.
Easiest cloud server provider for beginners. Create a Droplet running Ubuntu 22.04 LTS ($4 - $6/month).
Visit DigitalOcean →
Amazon Web Services offers 12 months free on t2.micro / t3.micro instances running Linux.
Affordable European/Global VPS hostings starting at €3.50/month with high CPU & NVMe speed.
Visit Hetzner Cloud →Connect to both your newly created Cloud VPS servers via SSH (using PowerShell or Windows Terminal) and install MySQL Server:
# Connect via SSH to Server A & Server B
ssh root@YOUR_SERVER_IP
# Update packages and install MySQL Server
sudo apt update && sudo apt install -y mysql-server
sudo systemctl enable --now mysql
Edit /etc/mysql/mysql.conf.d/mysqld.cnf on Server A:
[mysqld]
bind-address = 0.0.0.0 # Allow external connection
server-id = 1 # Primary Unique ID
log_bin = /var/log/mysql/mysql-bin.log
gtid_mode = ON
enforce_gtid_consistency = ON
Restart MySQL and create the Replication User:
sudo systemctl restart mysql
sudo mysql -u root -p
-- Inside MySQL prompt on Server A:
CREATE USER 'repl_user'@'SERVER_B_IP' IDENTIFIED BY 'YourStrongPassword123!';
GRANT REPLICATION SLAVE ON *.* TO 'repl_user'@'SERVER_B_IP';
FLUSH PRIVILEGES;
Edit /etc/mysql/mysql.conf.d/mysqld.cnf on Server B:
[mysqld]
bind-address = 0.0.0.0
server-id = 2 # Replica Unique ID (Must differ from Server A!)
gtid_mode = ON
enforce_gtid_consistency = ON
read_only = 1
Connect Server B to Server A inside Server B's MySQL prompt:
CHANGE REPLICATION SOURCE TO
SOURCE_HOST='SERVER_A_IP',
SOURCE_USER='repl_user',
SOURCE_PASSWORD='YourStrongPassword123!',
SOURCE_AUTO_POSITION=1,
SOURCE_SSL=1;
START REPLICA;
-- Verify replication is running:
SHOW REPLICA STATUS\G
Once your online servers are up, open config.php in this project folder (d:\wamp64\www\2online\config.php) and update lines 12 & 19 with your server IP addresses!
define('DB_PRIMARY_HOST', 'SERVER_A_IP'); // Server A IP
define('DB_REPLICA_HOST', 'SERVER_B_IP'); // Server B IP