Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Move Your Magento Store to a New Server

This guide walks you through moving a Magento online store from one hosting server to another without losing products or orders.

How-To Guides2 min read13 steps

What gets moved?

Magento is software for running an online shop. A Magento store has two parts. The first is the files: the code, themes and product images. The second is the database, which is like a big filing cabinet that holds products, customers and orders. You must move both.

Warning: do not switch off your old server until the new one works. Keep the old copy as a backup.

Steps

  1. On the old server, put the store in maintenance mode so no new orders arrive during the move:
php bin/magento maintenance:enable

Run this from your Magento folder. It shows visitors a "back soon" page.

  1. Make a copy of the files. Compress the Magento folder into one archive:
tar -czf magento-files.tar.gz /path/to/magento

This packs the whole folder into one small file. Replace the path with your own.

  1. Export the database:
mysqldump -u DBUSER -p DBNAME > magento-db.sql

This saves all your store data into a text file. Replace DBUSER and DBNAME with your own. Your old app/etc/env.php file shows them.

  1. Copy both files to the new server. You can use SFTP, or the scp command.
  2. On the new server, create an empty database and a database user with full rights to it. You can do this in your control panel under MySQL Databases.
  3. Import the data into the new database:
mysql -u NEWUSER -p NEWDB < magento-db.sql
  1. Unpack the files into the new web folder:
tar -xzf magento-files.tar.gz
  1. Open app/etc/env.php and update the database name, user and password to the new ones.
  2. If your domain changes, update the base URLs in the core_config_data table.
  3. Clear the cache and fix file permissions:
php bin/magento cache:flush
php bin/magento indexer:reindex

The first command clears stored copies of pages. The second rebuilds the search and price tables.

  1. Test the store using a temporary link or your computer's hosts file.
  2. When all works, point your domain's DNS to the new server. DNS is the internet's phone book that tells browsers where your site lives.
  3. Turn maintenance mode off:
php bin/magento maintenance:disable
Tip: Ask Hostvento support if you need help with the new server's PHP version or settings. Magento is picky about versions.

Quick recap

  • Move both the files and the database.
  • Use maintenance mode while you copy.
  • Update env.php on the new server.
  • Test first, then change DNS.