1

By default all my tables and columns are in some weird collation (latin1_swedish_ci). I would like to change them to "utf8_unicode_ci" but as I have 100 tables and many columns I would like to do this with one command. Does anyone know how to do it?

Maxitrol
  • 43
  • 4
  • 1
    Possible duplicate of : http://stackoverflow.com/questions/10859966/how-to-convert-all-tables-in-database-to-one-collation – John Cogan Mar 31 '17 at 15:19

1 Answers1

0

You can run this in PHP:

$con = mysql_connect('server_name','user_name','password');
mysql_select_db('database_name');
$result = mysql_query('show tables');
while($tables = mysql_fetch_array($result)) {
        foreach ($tables as $key => $table_name) {
          mysql_query('alter table $table_name convert to character set utf8 collate utf8_general_ci');
}}
Yuval Pruss
  • 8,716
  • 15
  • 42
  • 67