Changing MySQL from Latin Encoding to UTF-8

I recently realized that I made a big mistake and encoded things on the front end in UTF-8 and on the database side on latin1.

I am going to switch my MySQL db to UTF-8. Is there a “good practice” for such a procedure? Any recommended steps I can take? What are the pitfalls that I should follow?

Thanks Alex

+3
source share
3 answers

The main (and most common) trap will hopefully ALTER DATABASE … DEFAULT CHARACTER SETeither ALTER TABLE … DEFAULT CHARACTER SETchange the encoding of existing columns.

These statements only affect tables and columns created after you made these statements.

ALTER ,

ALTER TABLE mytable CONVERT TO CHARACTER SET UTF8;
+5

( , , ), , "" .

, ( ) , : .

& szlig; . . - " worng characters" , ...

MsSQL latin1 , utf-8 ( linux):

mysqldump --opt --quote-names --skip-set-charset --default-character-set=latin1 mydatabase > /tmp/dump.sql
mysql --default-character-set=utf8 mydatabase < /tmp/dump.sql
+3

Source: https://habr.com/ru/post/1789022/


All Articles