How to rename your WordPress database tables prefix after the installation

It’s really easy. You just need a plugin: Change DB Prefix

  • Make a backup of your database (and maybe your wp-config.php)
  • Make sure the webserver owns the whole WordPress directory (i.e. if you’re using Apache Web Server and your WordPress files resides inside /var/www/, just make sure to sudo chown -R www-data:www-data /var/www/
  • Also issue a sudo chmod -R 755 /var/www/ to give the webserver the ability to write to files but only read/execute to others.
  • Go to the plugin screen inside your WordPress admin panel, set the new prefix and run it.
  • Done.


Convert your WordPress Database Charset and Collation to utf8

In the wp-config.php file there are two lines that define your MySQL database charset and collation.

define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', 'utf8_general_ci' );

These lines should match those of your database but it’s not always like that; maybe you want to migrate the database content into another one (which is CHARACTER SET utf8 COLLATE utf8_general_ci) or maybe you just want to set reasonable defaults for your blog (avoiding the defaults, which more often than not are unknown).

Enter Utf8ize. It’s a simple WordPress Plugin but it’s a life-saver.

The goal in these conversions is always to decide on what charset/collation combination you want to use (UTF8 being the best choice in almost all scenarios) then to convert all tables/columns in your database to use that charset. At that point you can set DB_COLLATE and DB_CHARSET to the desired charset and collation to match.

It reads your database and generates SQL statements for every table and column. Then you simply copy/paste the statements into phpMyAdmin or Adminer and execute.

Just remember to change your wp-config.php accordingly and pay attention to the generated SQL statements for the specific collation (may be utf8_general_ci or utf8_unicode_ci). Set the correct values in the wp-config.php right after you run the SQL statements and you’re done.