I deal with a lot of database dumps. So this post is a must for me.
We seriously see a ton of customers coming in with the type of databases that are a nightmare to move over. When you’re dealing with special characters in a database, you have to make sure that the charset and collation are dumped *with* the database, so that when you move it to another server the tables and data create properly. The biggest annoyance so far is converting tables back to UTF-8, as when this is done through the MySQL shell or phpmyadmin is had to be done table-by-table. So, I wrote this simple PHP script to do it all at once…
The script is quite simple; I can just simply:
$sql = “ALTER TABLE $table DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci”;
Where $table = each table in the database.