How to migrate a database between servers
Updated 7/20/2026
Whether you are moving to a bigger plan or changing servers, moving a database is three steps: dump on the old server, transfer, restore on the new server.
MySQL
# on the old server
mysqldump -u root -p mydb | gzip > mydb.sql.gz
# transfer to the new server
scp mydb.sql.gz root@NEW_IP:/tmp/
# on the new server
gunzip < /tmp/mydb.sql.gz | mysql -u root -p mydb
PostgreSQL
# on the old server
pg_dump -U postgres mydb | gzip > mydb.sql.gz
scp mydb.sql.gz root@NEW_IP:/tmp/
# on the new server
gunzip < /tmp/mydb.sql.gz | psql -U postgres mydb
How to reduce downtime
- Do a first dump and restore in advance, so the new server has most of the data.
- At cutover, stop writes on the old server, take a final dump and restore it.
- Switch the application to the new database address.
Tip
With hourly billing, you can run both servers in parallel during the migration and delete the old one as soon as you are sure everything works. Keep the dump on a Backup Box as a safety net.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
How to secure MongoDB with authentication
By default, MongoDB runs without a password. Here is how to enable authentication and create an admin user.
Updated 7/20/2026DatabasesHow to connect an app to a remote database
Allow access to a database from another server, securely: bind address, dedicated user and firewall.
Updated 7/20/2026DatabasesHow to automate database backups with cron
Schedule daily MySQL or PostgreSQL backups with cron, with automatic retention, and send them to a Backup Box.
Updated 7/20/2026