How to migrate a database between servers
Updated 11/29/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 install and secure PostgreSQL on Ubuntu
Install the most advanced open-source database and configure it safely: password, scram-sha-256 authentication and controlled access.
Updated 11/29/2026DatabasesHow to install and secure MySQL on Ubuntu
Install MySQL or MariaDB on your VPS and secure it properly: root password, removing test accounts and controlled access.
Updated 11/29/2026DatabasesHow to create a MySQL user and grant privileges
Create dedicated MySQL users per application and grant exactly the privileges needed, step by step.
Updated 11/29/2026