Closed kevinmamaqi closed 1 year 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.
wp export db
sed --in-place --expression 's#`wp_#`stacked_#g' database-file-2020-05-21-77387c0.sql
sed --in-place --expression 's#'wp_user_roles#'stacked_user_roles#g' database-file-2020-05-21-77387c0.sql
sed --in-place --expression 's#'wp_capabilities#'stacked_capabilities#g' database-file-2020-05-21-77387c0.sql
sed --in-place --expression 's#'wp_user_level#'stacked_user_level#g' database-file-2020-05-21-77387c0.sql
The wp config
command will only make adjustments to your wp-config.php
file. It doesn't make changes to the database.
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...