Vannkorn

Full Stack Web Developer

Close

Export WordPress DB using wp-cli

With wp-cli we need only run one command to achieve it, and most importantly, it won't affect the actual database we are exporting from.

Ads: Register now via this link to receive $100 credit from Vultr

Image by rawpixel.com on Freepik

There are many works related to WordPress we can do with wp-cli to fasten our development workflow.

The most useful one for me is the easy way to dump DB from local/staging environments to production or vice versa. Previously, to achieve this, I need a plugin or the search-replace DB framework by interconnectit.

With wp-cli we need only run one command to achieve it, and most importantly, it won’t affect the actual database we are exporting from.

To do so, run the following command and hit Enter:

wp search-replace 'https://old-url.tld' 'https://new-url.tld' --export=db-name.sql

When finished, the database with the new URL will be dumped and ready to deploy.

Leave a Reply

Your email address will not be published. Required fields are marked *