wp-cli / db-command

Performs basic database operations using credentials stored in wp-config.php.
MIT License
71 stars 59 forks source link

Is it possible to wp db import or wp db export changing the table prefix #161

Closed kevinmamaqi closed 1 year ago

kevinmamaqi commented 4 years ago

In my workflow I rsync and use wp cli via SSH to import/export the database and then do a search-replace to update the URLs, etc... While it works perfectly I am forced to use the same DB prefix, is it possible to change it dynamically when exporting or importing using wp cli? Perhaps wp config update table prefix...

austinginder commented 4 years ago

I don't know how to do this solely using WP-CLI however here is one way to accomplish this using WP-CLI and sed. For this example I'll export a database with prefix wp_ then change it to stacked_ within the .sql file itself.

The wp config command will only make adjustments to your wp-config.php file. It doesn't make changes to the database.