views:

4121

answers:

3

It seems to me that phpMyAdmin imports tables by default with collation latin1_swedish_ci, how i change this?

+3  A: 

This is not a phpMyAdmin question.

Collations are part of recent MySQL releases, you must set the default collation of the server (or at least of the database) to change that behaviour.

To convert already imported tables to UTF-8 you can do (in PHP):

$dbname = 'my_databaseName';
mysql_connect('127.0.0.1', 'root', '');
mysql_query("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
$res = mysql_query("SHOW TABLES FROM `$dbname`");
while($row = mysql_fetch_row($res)) {
   $query = "ALTER TABLE {$dbname}.`{$row[0]}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci";
   mysql_query($query);
   $query = "ALTER TABLE {$dbname}.`{$row[0]}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
   mysql_query($query);
}
echo 'all tables converted';

Code snippet taken from here.

Tomalak
+2  A: 

In your Mysql configuration change the default-character-set operative under the [mysqld] tab. For example:

[mysqld]
default-character-set=utf8

Don't forget to restart your Mysql server afterwards for the changes to take effect.

Eran Galperin
A: 
Jay bharat