Is there a SQL or PHP script that I can run that will change the default collation in all tables and fields in a database?
I can write one
I think the fastest way is with phpmyadmin and some jQuery on console.
Go to table's structure and open chrome/firefox developer console (normally F12 on keyboard):
run this code to select all fields with incorrect charset and start modify:
var elems = $('dfn'); var lastID = elems.length - 1;
elems.each(function(i) {
if ($(this).html() != 'utf8_general_ci') {
$('input:checkbox', $('td', $(this).parent().parent()).first()).attr('checked','checked');
}
if (i == lastID) {
$("button[name='submit_mult'][value='change']").click();
}
});
when page is loaded use this code on console to select correct encoding:
$("select[name*='field_collation']" ).val('utf8_general_ci');
save
change the table's charset on "Collation" field on "Operation" tab
Tested on phpmyadmin 4.0 and 4.4, but I think work on all 4.x versions