Like I’d already announced in my previous post, I recently moved this website from the domain bytesandbikes.be to woutdillen.be, and I moved it between two servers in the same go. Because I wanted a new start, because using my name for the website looked a bit more professional, because I haven’t been cycling all that much recently (for its own set of reasons), because I wanted to know how to do it, … you pick one. And To make the move, I was looking at a couple of tutorials online, but none of them really did it for me. So I thought I’d write my own blog post to let you know what did. And – like many of the tutorials I’d post on this website – as a point of reference for my future self, if I ever had to do something similar again.
FYI: the hosting service that I use (and followed these steps with) is one.com. So if you use that too, these steps should work for you. But this is by no means a plug for one.com. As will become more obvious below, I’m sometimes a bit frustrated with this company, and others may give you easier access to your data. So do your research and find a service that suits your needs. I haven’t switched (yet) because of laziness and because so far in the end I’ve always been able to force what I tried to do regardless of their limitations.
Not much to move? Try WP’s official Plugin
When I started moving the website, I already had a little bit of experience moving content from one WP website to another. Like it says on my About page, some of my oldest posts here are from a food-blog I was part of a long time ago. And that process was pretty simple. If you just need to move a couple of posts between WP websites, you can use a very easy plugin that was developed by the WordPress team called WordPress Importer. If I’m not mistaken, WP itself points you in this direction if you go to Tools > Export (and you don’t have the plugin installed yet).
If that’s all you need you can just:
- download that plugin,
- go to Tools > Export,
- download your materials,
- go to your new website,
- download the plugin there too
- go to Tools > Import
- import the files you just downloaded
It’s pretty easy, self-explanatory, and painless. But it doesn’t always work perfectly, especially if you have a lot of posts, and use a lot of links and images (which will not always down/upload and link correctly. In my case, it was too much work to fix all the errors produced in the process. So after going down this road again for a little while, I decided to do it differently this time.
Migrate your WP website manually
So I looked around for a good tutorial, but most of the ones that I found either required SSH access to the website, or worked with old or paid plugins. The hosting service I use doesn’t grant me SSH access (at my current, cheap plan), and I didn’t want to pay for a plugin either, because I figured this would have to be possible (and, if you know how, pretty easy) to DIY for free. After looking at a couple of tutorials, I came across Cloudways‘ post ‘Migrate WordPress to Another Host‘, which seemed to come close to what I had in mind. So I started from there, and adjusted what I needed to adjust along the way. So that’s what I’ll outline below.
Step 1: Move Your Files
First you’ll need to move your files from one server to the other. Cloudways here prefers doing it through SSH, but like I said that wasn’t an option for me. So I went with the FTP option. I’m assuming here that your WP website is in the root of your old server, and that you’re taking it to the root of your new server. If that’s not the case, take that into account when you move around files.
Actually, I first tried doing it just through the File Manager of my hosting service, and download all my files from there. But although this is not even that big of a website, it took ages to download my files and I got frustrated pretty quickly. So I switched to the free, open source (S)FTP tool that I work with a lot: Cyberduck.
Once you are into your website’s filesystem (whichever way you do that), and download your WP-files onto your computer. You can basically just download everything that’s in the root of your serve, but if you (like me) have a bunch of other stuff on there too that you don’t necessarily want to move to the new server, you can be more selective. In that case, you’ll need all of the files and folders that start with wp-
, the index.php
, the license.txt
, the readme.html
, and xmlrpc.php
. So download those, and then just upload them to your new server (probably again using something like Cyberduck.
Step 2: Migrate your Database
So now you have all of your files on your new website, but you’ll need to duplicate the database your original WordPress website uses before you can actually start using your new website. Here, Cloudways suggested using a plugin called UpdraftPlus. But his blogpost was a year old, and the plugin had changed a bit in the meantime. And it never really worked for me. So I figured out my own way to do it, without using any plugins at all. All you need is access to your website’s PhpMyAdmin service – which I hope most host servers should let you do. Mine did, and like I said it’s pretty restrictive.
Step 2.1 Export your original database
In the control panel of your old server, find where you can access its PHP and database settings (probably under Advanced Settings somewhere). There, select your database, and visit its PhpMyAdmin panel. There, in the top menu bar, you should be able to see an Export
tab. If you go there, you can just select (the default?) ‘Quick’ export method, and export it in the SQL
format. Hit Go
to export. Downloading this .sql
file onto your computer should take less than a second.
Step 2.2 Build a new (empty) database on your new website
Visit a similar settings-page in your new server. If there’s already a database there (and you can only have one database on your server, like me), delete that database, and make a new one. If you’re looking for a name, the most logical name you can give your database is domainname_domain
. (For my old website, that would have been bytesandbikes_be
). You’ll also be asked to create a user for your database, and a password. Do that, and note all of this information down.
Step 2.3 Modify your .sql
file
Now that you have this information, it’s time to update your .sql
file before you upload it to your new database. Cloudways moved directly to importing this file into your database, but some permissions issues prevented me from doing that. So we’ll make some changes to the file first.
So what you want to do is: take the .sql
file you just downloaded, and open it in a text editor like SublimeText. Around line 22, you should see the name of your old database mentioned three times. That’s where we now want to change it to the name of your new database. And let’s just use Find and Replace all to do that, just for good measure. So replace all instances of your olddatabasename
with your newdatabasename
.
Then, we want to do the same for all the links in your database. Cloudways suggests doing this later with another plugin, but I didn’t want to take the chance that that plugin wouldn’t work well either, and that I had to find another way to do it regardless. So I just changed everything here.
To do so, find all instances of your olddomainname.domain
) to your newdomainname.domain
(in my case: from bytesandbikes.be
to woutdillen.be
).
Granted, this is a blunt way of doing it. Like trying to slice a block of cheese with a wood axe. But it worked for me. So there.
Step 2.4 Import your new .sql
file
Now, all you need to do, is upload your new .sql
file to your new database. Go to the PhpMyAdmin of your new server, find the import
tab in the top menu (right next to the export
tab), and upload your new file.
Step 2.5 Check your siteurl
and home
Once you’ve done this, stay in PhpMyAdmin for a little while. Hit the database
tab (to the left of import
and export
). There, select your database from the list (the only item in there, if you’re following this tutorial to the letter). There, select the 0_options
table (the 0
in there could be another number). Once you’re there, the first two items in the list should be siteurl
and home
. Normally, if you’ve changed the URL as explained in Step 2.3, both of these should link to your new domain name (https://newdomainname.domain
). If so: great. If not: hit edit
and do it yourself.
Step 3 Update your config file
Once this is done, we move out of PhpMyAdmin, and go back to the File Manager of your host server (or, again, through a service like Cyberduck), and find the wp-config.php
file (in the root). There, simply replace the credentials with the ones you noted earlier (in Step 2.2), i.e. DB_NAME, DB_USER, and DB_PASSWORD. In addition, I also had to change DH_HOST from olddomainname.domain.mysql
to newdomainname.domain.mysql
.
And that’s it! You should now be able to visit your new domain’s URL, and access your new website, which should look more or less exactly the same as your old website! Go into your /wp-admin
, change the website title (Settings > General) if you need to, and have fun!