howto:mysql-latin1-to-utf8
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| howto:mysql-latin1-to-utf8 [2022/03/25 15:23] – Wuff | howto:mysql-latin1-to-utf8 [2023/05/29 11:55] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| < | < | ||
| mysqldump -u username -p --add-drop-table database-name | replace CHARSET=latin1 CHARSET=utf8 | iconv -f latin1 -t utf8 | mysql -u username -p -D database-name | mysqldump -u username -p --add-drop-table database-name | replace CHARSET=latin1 CHARSET=utf8 | iconv -f latin1 -t utf8 | mysql -u username -p -D database-name | ||
| + | </ | ||
| + | |||
| + | Directly via mysql, note utf8 charset is not fully compatible with UTF-8, so better use utf8mb4: | ||
| + | < | ||
| + | #change default only | ||
| + | ALTER TABLE tablename CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
| + | #convert charset of data | ||
| + | ALTER TABLE tablename convert to character set utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
| + | |||
| + | #changes for whole database | ||
| + | ALTER DATABASE databasename CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
| + | ALTER DATABASE databasename convert to character set utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
| </ | </ | ||
howto/mysql-latin1-to-utf8.1648221784.txt.gz · Last modified: (external edit)