I take a few minutes here to propose an interesting alternative to successfully migrate its WordPress database when going into production or a change of host, so applicable when creating a website, a redesign or change of provider.

Migrating the database: a priority

Your database is the focal point of your web application. Successfully exporting to a third-party server (migrating it) is often seen as a stressful phase. We usually first export its files with an FTP client like FileZilla after making the necessary configuration changes on the configuration file wp-config.php, before exporting the database.

The DBSR script works, cool. But since we have access to the services of our host at this stage, we try to reverse the migration process of the site to save some time.

Your host: your new friend

For the administration, many hosts offer similar solutions and you can probably connect to a cPanel management interface. This is where you will connect to PHPMyAdmin to import your databases, and you will define roles and permissions to manage them.

Looking more closely you should find among the sections of cPanel, a heading ” File Manager ” … it’s very simple: if you go there, you will see a tree of folders (directories) representing the disk space allocated to your accommodation. What interests us here is the path leading to your personal directory ( path in English in the text). This is where the public_html folder where you will export your WordPress files is located.

Your WordPress database needs this path for the CMS to correctly access your files. This path is recalled next to the root of your disk space, and it corresponds to the path from there to the directory “www” (” www ” is only an alias of ” public_html “, it actually points to the same folder). You add the public directory to the primary path and you get / home / yourFolder / public_html.

WP Migrate DB: a WordPress plugin to migrate your databases

We are primarily interested in exporting the database to avoid having to make unnecessary file transfers.

WP Migrate DB is a WordPress extension allowing you to export your databases by modifying only the new domain and the new path to your files. The plugin offers, from its free version, a gzip compression for large databases, and a range of interesting options such as excluding comments identified as spam or revisions.

The process of using the plugin usually involves a double installation of the plugin , remote server side and local (or on a version of WordPress installed in your two hosts in ca change of provider). This makes it possible to retrieve new information from the plugin installed on the target server to inject them at the level of the one on the source server, and to provide it with the two information necessary for converting the data. Yes, but we can do without this first phase!

This is where we need our file path. We use it to feed the ” new file path ” field .

You have to say, “But if I only have to do that, why not start right now with this step? “. And precisely because you will need this way to carry out the export.

After installing the plugin on the version to be migrated, go to the “Tools / Migrate DB” menu . Fill in the ” new file path ” field and the ” new URL ” field in the “Replace” column. Click on the “Export” button and you download the converted version of your database.

WP Migrate DB plugin interface for migrating a WordPress database

I remind you that you fill in the field dedicated to the URL “new url” according to your project: your address on your local server in case of repatriation of the site on your computer, your new domain name if you change, the same domain name if you change host.

If you transfer the site to your local server (MAMP, WAMP, or LAMP), your new URL depends on your server configuration and your system. If you have set up a VirtualHost and your host system file, you can use an arbitrarily defined URL. But if you work basically on a subdirectory of the folder “www” (or htdocs on Mac), your URL will be of the type:

  • http: // localhost / my-directory
  • http://192.168.0.1:8888/my-directory (on Mac)

Here you have to go back to the PHPMyAdmin part of your cPanel interface, select your newly created database and import the downloaded file.

I noticed that the compression is sometimes tricky, uncheck the option and start again if you have problems (the export itself only takes a few minutes).

File path not found

It may be that for some reason I do not have this file path. Do not panic, a phone call to your host will not cost you anything. If it is unavailable … well, you will not cut, it will install a brand new WordPress (blank) on the target server after filling the lines of the wp-config file on your database.

You transfer the contents of the WordPress folder to the “www” directory with an FTP client such as FileZilla.

You then go directly to the WordPress administration interface that you have just installed, by adding ” / wp-admin ” to your domain (http://your.domain.com/wp-admin).

Go to the “Extensions / Add” menu to search WP Migrate DB (it’s free and it’s good!). You install the plugin, then via the menu “Tools / Migrate BD” you find your migration interface. And there, miraculously, the “Find” column gives you the path to the files at your new host (or your local server, depending on what you want to do). You copy this information into the site window to migrate and launch the export.

Installing the Migrate DB WP plugin

You can now export your files instead of the blank WordPress installation, go to your cPanel to (create if you have not already done so) and import your tables into your new database.

Migrating your WordPress database: it’s easy

I summarize the steps of the migration of your WordPress database (and your site):

  • You start anyway by creating your database on the target server as well as a privileged user with a password to access this database
  • You will find via the “file system” menu, the local path to your files
  • If you do not find it, you call your host
  • If it is not available, you quickly install a version of WordPress and the WP Migrate DB plugin on this target server and from there you retrieve this information.
  • You install the WP Migrate DB plugin on the version to migrate, and you fill in the information retrieved earlier as well as the new URL, before launching the export and download the file to your hard drive.
  • You go back to your cPanel (or similar), go to PHPMyAdmin and select your database before starting the import of the downloaded file earlier.
  • Finally, you make an FTP transfer of your files from the source server to the target server and you enjoy your site!

Here! So you have a simple way to migrate your WordPress database and transfer your site from your local server to that of your host, or your former painful provider to what is now your brand new server!