Convert back WP MU to WordPress

Godaddy’s WordPress only support single user, not the MU version, have to convert back original WPMU version to single user version.

Since I have to install multiple version of WordPress, each of them has its own DB. I put a .sid for each of mysql DBs as original .my.cnf file.

Contents like this:

# freelamp.com
[client]
host = frexxxxxxx.db.7114699.hostedresource.com
user = frexxxxx
port=3306

[mysql]
database = frexxxxxxxx

Then create alias in .bash_profile for each mysql instance:

alias mysql.albertxu=’mysql  –defaults-file=~/.albertxu -p ‘
alias mysql.freelamp=’mysql  –defaults-file=~/.freelamp -p ‘

So that I can just use mysql.freelamp to log into DB.

The first step is to import the original exported wpmu DB, it includes all the other users tables(blogs), we’ll remove them later.

I write a rename.sh, to rename the required tables:

-bash-3.2$ cat rename.sh
#!/bin/bash
id=$1
[ -z “$id” ] && echo “Syntax: $0 blog_id” && exit 0
FILE=$id.sql
echo > $FILE

# we ignore this two tables: cas_count cas_image
for t in  posts commentmeta comments links options postmeta terms term_relationships term_taxonomy
do
echo “DROP TABLE IF EXISTS wp_$t ;” >> $FILE
echo ALTER TABLE wp_”$id”_$t RENAME TO wp_$t “;” >> $FILE
done

echo UPDATE wp_options set option_name=\”wp_user_roles\” WHERE option_name=\”wp_”$id”_user_roles\” “;” >> $FILE
echo UPDATE wp_usermeta set meta_key=\”wp_capabilities\” WHERE meta_key=\”wp_”$id”_capabilities\” “;” >> $FILE
echo UPDATE wp_usermeta set meta_key=\”wp_user_level\” WHERE meta_key=\”wp_”$id”_user_level\” “;” >> $FILE

cat $FILE

Check the output of the above script, then run mysql.freelamp < 2.sql ( in the example, $id = 2 ), you should see all the blog contents in original WPMU site now migrated. The remain thing is log in the control panel to change “Media” folder path and PermsLinks Settings.

And remove non-used users also.

At last, you should remove all these not in using other user’s tables.

SQL command: show tables like “wp\__\_%”  can list all the others tables not needed, just filter them to a script and make it like

DROP TABLE IF EXISTS $tablename.

All set.   LOL.