It is necessary to change the collation of all the tables in a database from mysql, I have installed by default with latin_swedish and I want to change it to utf8_general_ci, usually the documentation that we are given to do it one at a time, even with the phpmyadmin, we have an option to do it completely to the whole database, but it does not work very well, at least it does not work for me, it did not give me an error, but it did not do anything, but with this script we can do it simple way, we throw this statement sql.
SELECT CONCAT(
'ALTER TABLE ', table_name, ' CHARACTER SET utf8 COLLATE utf8_general_ci; ',
'ALTER TABLE ', table_name, ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ')
FROM information_schema.TABLES AS T, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` AS C
WHERE C.collation_name = T.table_collation
AND T.table_schema = 'your_database_name'
AND
(C.CHARACTER_SET_NAME != 'utf8'
OR
C.COLLATION_NAME not like 'utf8%')
Once we return the set of sentences, we simply need to copy and launch it again, and all the collate of all the tables are changed to what we needed.