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?
            Asked
            
        
        
            Active
            
        
            Viewed 116 times
        
    1 Answers
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
- 
                    Won't this convert just tables? What about columns? Each column also has collation set. – Maxitrol Mar 31 '17 at 18:19
