Rename WordPress’ Database Prefix with WP-CLI

I wanted to update the database prefix one this site, but most of the tutorials out there have you do it manually. There are some plugins available, but I didn’t trust most of them, and the ones that I did were kind of bloated with other features, and I didn’t want to mess with the cleanup, etc.

So, I wrote a WP-CLI command to do it instead.

Install: wp package install iandunn/wp-cli-rename-db-prefix
Use: wp rename-db-prefix new_prefix_

 

8 thoughts on “Rename WordPress’ Database Prefix with WP-CLI

  1. Hello Ian,

    Just like to thank you for creating that package. I did install it yesterday and it worked wonderfully, thank you for your work on this.

    Regards

  2. Hi,

    Thank you for this. However I’ve run the install but I get Error: ‘rename-db-prefix’ is not a registered wp command. See ‘wp help’. when trying to run the command after install.

    Thanks

  3. Hi Ian,
    Actually from trying the install again it seems to stop at ‘Updating dependencies’. I’m not sure why.

    Thanks

  4. Yes, it looks like your package is broken

    Error: ‘rename-db-prefix’ is not a registered wp command. See ‘wp help’. when trying to run the command after install.

Leave a Reply to whataboutbob Cancel reply

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