Created
June 16, 2011 14:02
-
-
Save rutger1140/1029277 to your computer and use it in GitHub Desktop.
Convert MySQL character set and collations to utf8_unicode_ci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Convert MySQL tables to utf8_unicode_ci | |
*/ | |
// Prevent accidental execution | |
die("Please open and update this file before executing it :)"); | |
// Your connection | |
mysql_connect("localhost","development","development"); | |
mysql_select_db("your-database-name"); | |
// Convert code | |
$res = mysql_query("SHOW TABLES"); | |
while ($row = mysql_fetch_array($res)){ | |
foreach ($row as $key => $table){ | |
mysql_query("ALTER TABLE " . $table . " CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci"); | |
echo $key . " => " . $table . " CONVERTED<br />"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment