How to Move a MySQL Database to a Bigger VPS Without Downtime
When your database outgrows its server, queries slow down, connections pile up, and a busy hour can push the whole site over. The fix is to move MySQL database to bigger VPS hardware with more RAM, faster disk, and headroom for growth. Done the right way, the move needs only a short read-only window of seconds to a few minutes, not hours offline. This guide walks through the replication method step by step, with a dump-and-restore fallback for smaller databases.
When a Bigger VPS Actually Fixes the Problem
A bigger VPS helps when MySQL is short of RAM for the buffer pool, when disk I/O lags behind write load, or when CPU stays high during normal traffic. Check first, because a slow query or a missing index can look like a hardware problem. Look at slow query logs, buffer pool hit rate, and disk wait before you pay for a larger server. If the real fault is a full table scan on every page load, new hardware will only hide it for a while.
Size the new server from measured load, not from a guess. Note peak connections, working set size, and daily write volume, then pick a plan with RAM above the working set plus room for the operating system.
Pick a Method: Replication or Dump and Restore
Two methods cover most moves. Replication keeps a live copy on the new server and syncs changes until you switch over. Dump and restore takes a full export, copies it across, and loads it on the new server. The table below shows when each one fits.
| Method | Best for | Downtime | Risk |
|---|---|---|---|
| Replication | Live sites and large databases | Short read-only window | More setup, needs binlog access |
| Dump and restore | Small databases and maintenance windows | Minutes to hours offline | Simple, but writes stop during the load |
For a live site, replication is the safer pick. A mysql replication migration lets the new server catch up while the old one keeps serving traffic, so the final switch is short. Dump and restore suits a small database, a staging copy, or a site that can sit offline for a planned window. A mysqldump without downtime is not real for a live database, because writes during the export either get missed or force a lock. Use the dump as a backup and a test load, not as the live cutover path for a busy site.
Prepare the New VPS First
Build the new server before you move any data. Install the same MySQL or MariaDB major version as the source, because replication across major versions can break on changed syntax or defaults. Copy the configuration across, then adjust the buffer pool and connection limits for the larger RAM. After the move, spend time on MySQL tuning settings for the new size, since values tuned for a small server will waste the extra memory.
Work through a mysql database migration checklist before the first copy: confirm disk space for the data plus binary logs, open the MySQL port only to the source server IP, set matching time zones, create the same database users with the same grants, and test the network speed between the two servers. Make a fresh backup of the source and confirm you can restore it. If you have never tested a restore, read how to test your backup restores without breaking production, and run that test on the new server before migration day. A backup you have never restored is a hope, not a plan.
How to Move MySQL Database to Bigger VPS With Replication
Replication needs binary logging on the source and a replication user the new server can connect with. Turn on binary logging and a unique server ID on the source if they are not already set, then restart MySQL on the source during a quiet moment. That restart is the one planned interruption before migration day, so do it early.
Create a replication user on the source:
CREATE USER 'repl'@'%' IDENTIFIED BY 'a-strong-password';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
FLUSH PRIVILEGES;
Take a consistent snapshot with mysqldump. The --single-transaction flag works for InnoDB tables and avoids locking the whole database during the export. The --master-data=2 flag records the binary log position inside the dump file, so the replica knows where to start.
mysqldump --single-transaction --master-data=2 --all-databases --routines --events > full.sql
Copy the file to the new server and load it. Then point the new server at the source with the log file and position from the dump header, and start replication:
CHANGE REPLICATION SOURCE TO
SOURCE_HOST='old-server-ip',
SOURCE_USER='repl',
SOURCE_PASSWORD='a-strong-password',
SOURCE_LOG_FILE='mysql-bin.000001',
SOURCE_LOG_POS=1234;
START REPLICA;
Check replication status on the new server. Both the I/O thread and the SQL thread should report Yes, and the lag should fall to zero. Let it run for at least a few hours under normal traffic so you can see it keep up with peak load. Keep in mind that replication and daily backups serve different jobs, and one does not replace the other. You still need regular backups on the new server after the move, so set up a schedule to back up MySQL databases automatically with mysqldump and cron once the new server is live.
Cut Over With a Short Read-Only Window
Cutover is the only part that touches live traffic, so plan it for a quiet hour. Lower the DNS TTL or the app connection setting a day ahead, so the switch spreads fast when you make it. Warn your team, and keep the old server running as a fallback.
- Put the app in maintenance mode or set MySQL on the source to read-only with
SET GLOBAL read_only = ON; - Wait until replication lag reads zero on the new server.
- Stop replication on the new server and promote it to primary.
- Point the app at the new server IP or hostname.
- Check the app loads, logins work, and new writes land in the new database.
That read-only window is usually seconds to a few minutes, depending on how fast lag drains and how quickly the app reconnects. Call it near-zero downtime only with that condition attached. A site with long transactions or a slow DNS change will take longer, so measure lag and connection time on a test run first.
Verify the Data After the Move
Do not delete the old server until you have checked the new one. Compare table counts between source and replica for the largest tables, and run checksums on a few of them. Test the actions users actually do: place an order, save a post, change a password, upload a file that writes a row. Check the app error log for connection errors and slow queries in the first hour, then again the next morning.
Watch the new server closely for the first day: buffer pool use, disk space, and the MySQL error log. If a query that was fast before turns slow now, check that indexes loaded correctly.
Roll Back if Something Goes Wrong
Keep the old server untouched for at least a few days after cutover. If the app fails on the new server, you can point it back to the old one, but only if no new writes have landed on the new server since the switch. Once users have written to the new database, a simple switch back would lose those writes, so the rollback path changes.
For that case, set up replication in the other direction before you cut over, or take a fresh dump from the new server and load it back to the old one. Test the rollback steps on staging first, and write down the exact commands, IPs, and config paths.
Mistakes That Cause Downtime or Lost Rows
Most failed moves come from the same short list. Skipping the backup before the first copy, mixing MySQL versions between source and replica, and forgetting stored routines, events, and triggers in the dump are the common ones. A dump without --routines and --events will load tables fine and then break the parts of the app that depend on those objects.
Other mistakes include opening the MySQL port to the whole internet for the replication user, leaving the old server writable after cutover so writes split across two databases, and deleting the old server the same day. Lock the replication user to the replica IP, set the old server read-only after the switch, and keep it for a week. That week of overlap costs little and saves the move if a late problem shows up.