How do I migrate a wordpress site hosted by digitalocean to another web host? It seems incredibly difficult.

It seems digital ocean doesn’t allow you to download a full local copy of the site, and it isn’t clear how to point mysql to another webhost either. Any tips?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

DigitalOcean does not block anyone from migrating their websites / applications around - WordPress included.

There are a few ways to do so - this is one.

  • ssh into your droplet
  • issue the following command(s):
DBNAME=$(grep DB_NAME "wp-config.php" | cut -d "'" -f 4); \
DBUSER=$(grep DB_USER "wp-config.php" | cut -d "'" -f 4); \
DBPASS=$(grep DB_PASSWORD "wp-config.php" | cut -d "'" -f 4); \
mysqldump -u${DBUSER} -p${DBPASS} ${DBNAME} > ${DBNAME}.sql

This will drop a copy of your database into the same directory as your wordpress installation. Please note this works only for a standard WordPress installation - This can also be done quite easily with phpMyAdmin if it is available.

  • package up everything using whatever archive tool you choose - I prefer zip - zip -r ../ /PATH/TO/WEBROOT

This will place a *.zip archive one directory up.

  • move the archive to the new server scp ../ USERNAME@IP_OR_HOSTNAME:/PATH/TO/WEBROOT

  • Leave your droplet

  • Within the new host create your new database using whichever tool is available or proffered

  • ssh into your new host and cd /PATH/TO/WEBROOT

  • unzip -d ./

  • copy the old wp-config cp wp-config.php wp-tempfile - we are only going to use this temporarily

  • edit the wp-config.php file updating the database connection details with that of your new host

  • upload the database

OLDDBNAME=$(grep DB_NAME "wp-tempfile" | cut -d "'" -f 4); \
DBNAME=$(grep DB_NAME "wp-config.php" | cut -d "'" -f 4); \
DBUSER=$(grep DB_USER "wp-config.php" | cut -d "'" -f 4); \
DBPASS=$(grep DB_PASSWORD "wp-config.php" | cut -d "'" -f 4); \
mysql -u${DBUSER} -p${DBPASS} ${DBNAME} < ${OLDDBNAME}.sql
  • remove zip archive and wp-tempfile rm -v wp-tempfile

Please note that this may need to be adjusted to suite your server setup for the source and destination server and wordpress installation - i.e. you may need to install and configure NGINX/APACHE, MySQL/MariaDB etc…

Another solution is to use something like this