WordPress Database replacing the easy way


I published an NPM package a small cli tool which does the exporting and replacing the URL for a WordPress website piece of cake. You can export and replace within 10 seconds (depending the size of the database and how fast you type).

I started this as a project for personal use, but decided to make it as an NPM package and publicly accessible. We all know the ritual for WordPress development.

  • Develop local using docker containers
  • Use git commit, git push (or FTP upload for old school hardcore people) to deploy
  • open phpmyadmin, find the database,export the database
  • find the file in the downloads folder (find which one is the latest from database (2).sql or database (3).sql or database (5).sqlbecause you deleted (4)
  • replace the local url with the staging/production url you can do it by:
    • using any text editor to search/replace the url or
    • using a plugin to import and replace url in the database
      • Install the plugin
      • Configure the plugin
      • Run the search/replace and wait to finish
      • Done Or do the following while you are in your project directory:
  • run devild db:export and follow the instructions to export your database in your current directory
  • run devild db:replace and follow the instructions to replace the url and create another file to keep the original one.
  • done ( ~10 seconds ⏳ )

This package is available at NPM Registry where you can install it by running yarn global add @perlatsp/devild or npm i -g @perlatsp/devild

Posted in