Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Collation to utf8_bin in one go

I have set up the Collation of all my database tables as latin1_swedish_ci and now I realise that I should use utf8_bin or utf8_general_ci.

How can I change the Collation in the tables to utf8_bin or utf8_general_ci in one go? Can I use a query or something?

like image 584
Run Avatar asked Jan 24 '11 16:01

Run


1 Answers

You'll simply need to run an ALTER on each of the tables as follows:

ALTER TABLE <table name> COLLATE utf8_general_ci;

If you also need to update the existing character encoding (unlikely by the sounds of things), you can use:

ALTER TABLE <table name> CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
like image 108
John Parker Avatar answered Oct 07 '22 02:10

John Parker