How to change Collation from latin1_swedish_ci to utf8_general_ci

If you want to change your database collation form from latin1_swedish_ci to utf8_general_ci then follow the below steps :

take the sql dump for the DB for which you want to change the collation :

example :

[email protected][#] mysqldump --opt test_shop > test_shop.sql

Now in the .sql dump file search for the collation for latin :

[email protected][#] cat test_shop.sql | grep -i latin1

now replace the latin collation to utf8 by running the command :

[email protected][#] replace latin1 utf8 -- test_shop.sql

finally restore the changed .sql dump file (in ex : it is test_shop.sql)

[email protected][#] mysql test_shop < test_shop.sql

That’s all you are done.