Can You Change the $table_prefix in WordPress when You Move a Blog? No!
I found this out the hard way – in moving a blog to another site, I dumped the SQL data for the blog, and then entered it into the new site (it’s a quick and dirty way of transferring a blog).
However, I thought I’d be creative, and change the database prefix from the default ‘wp_‘ to something more related to the blog.
That’s because I planned to combine multiple blogs on a single site, and wanted them to share a database (easier for backups).
However, once the tables are created, it’s VERY tricky to change the names.
For example, I thought I’d just go through and search and replace the SQL text
INTO `wp_
with
INTO `new_
and then
TABLE `wp_
with
TABLE `new_
However, these aren’t the only places where ‘wp_‘ occurs – and missing one of them (the user privileges) resulted in this error when I tried to log in:
“You do not have sufficient permissions to access this page.”
Now I know this is a common problem with WordPress MU – however, I had it with plain old vanilla WP (version 2.3.3 no less).
It didn’t help that I was doing several blogs at a time, and soon forget I had modified this database only – but when it became the only blog that wasn’t transferring properly, I became suspicious.
The moral? Tweak at your own risk – but be prepared to roll back if there’s a problem.
Another moral – change the WP extension in the wp-config.php file when you CREATE a new blog:
$table_prefix = 'new_';
‘wp_‘ will end up clashing sooner or later, and it’s convenient to pack multiple blogs into the same database (and a bit faster, I suspect). If they’re all wp_user, wp_posts, etc, then you can’t combine them later.
And as a side benefit, you can backup your blog’s database at one time – and you can easily find the blog tables if you choose the prefix carefully.









Leave your response!