Convert database to utf8

I converted my MySQL database from latin_swedish to utf8 as recommended by Andrew here: http://issues.freepbx.org/browse/FREEPBX-12148

MY_USER=YYY
MY_PWD=XXX
for DATABASE in $(sudo mysql -u${MY_USER} -p${MY_PWD} <<< "show databases;") ; do
	mysql -u${MY_USER} -p${MY_PWD} <<< "alter database ${DATABASE} character set utf8 collate utf8_unicode_ci;"
	for TABLE in $(sudo mysql -u${MY_USER} -p${MY_PWD} <<< "use ${DATABASE} ; show tables") ; do
		echo "### convert ${DATABASE}.${TABLE}"
		mysql -u${MY_USER} -p${MY_PWD} <<< "alter table ${DATABASE}.${TABLE} convert to character set utf8 collate utf8_unicode_ci;"
	done
done

It will echo some error messages about non-existing tables or tables which couldn’t be altered, but that is fine. It would be more work to exclude these tables than to just live with these errors/warnings.

Not all CDR records with umlauts or other special characters look good in UCP and FreePBX and i just have to figure out how to persuade HeidiSQL to do the same.