Skip to content

Instantly share code, notes, and snippets.

@Finkregh
Created May 20, 2011 11:54
Show Gist options
  • Save Finkregh/982780 to your computer and use it in GitHub Desktop.
Save Finkregh/982780 to your computer and use it in GitHub Desktop.
convert all collations (tables and rows) in a MySQL-DB to utf-8
<?php
// your connection
mysql_connect("localhost","root","");
mysql_select_db("");
// 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 . " =&gt; " . $table . " CONVERTED<br />";
}
}
?>
@Finkregh
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment