Feb
22
2010

How to change the collation for all tables in a MySQL database to UTF-8?

<?php
$db = mysql_connect("localhost", "username", "pass");
if(!$db) echo "Cannot connect  the  - incorrect details";
mysql_select_db('myuser_mydbname'); $result=mysql_query('show tables');
while($tables = mysql_fetch_array($result)) {
foreach ($tables as $key => $value) {
mysql_query("ALTER TABLE $value COLLATE utf8_slovenian_ci");
}}
echo "The collation of your  has been successfully changed!";
?>

Leave a comment

Get Adobe Flash playerPlugin by wpburn.com wordpress themes