Skip to content

Instantly share code, notes, and snippets.

@waynegraham
Created September 12, 2016 16:08
Show Gist options
  • Save waynegraham/3f614468bc9eb2694ac4c5fa0afb937f to your computer and use it in GitHub Desktop.
Save waynegraham/3f614468bc9eb2694ac4c5fa0afb937f to your computer and use it in GitHub Desktop.
Migrate Wordpress Site to Multisite
  • Create a dump of the mysql database being migrated (e.g. diglib) with mysqldump or wp-cli
$ cd path/to/wordpress-to-migrate
$ wp export ~/wordpress-`date +%Y-%m-%d`.sql
  • Edit the file to replace the the table prefix with the prefix and id used in the WPMU instance. This is the regex in vim:
:%s/wp_old/wp_1/g
:x
  • Make a backup of the WMPU instance with wp-cli or mysqldump
$ cd path/to/wordpress-multi-user
$ wp export ~/wordpress-mu-`date +%Y-%m-%d`.sql
  • "Restore" the edited SQL file from your original dump to the WPMU database. There's only one database in this file (the one you just overwrote the prefixes for) so it should update just those tables.
$ mysql -u wpmu-user -p wpmu-password wpmu-database < edited-wordpress.sql
  • Check if it worked. If it didn't, restore the wordpress-mu*.sql file.
$ mysql u wpmu-user -p wpmu-password wpmu-database < wordpress-mu*.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment