Answer the question
In order to leave comments, you need to log in
Is it possible to convert latin1 to utf-8?
The hosting had latin1 encoding for a very long time, I decided to look into the database, and instead of Russian characters there were krakozyabras
I understood the reason, but I don’t know how to fix and recode latin1 to utf-8 without losing the base itself ...
How to do it right, so that nothing didn't it break?
Answer the question
In order to leave comments, you need to log in
Save the database backup to a file
mysqldump --user=USERNAME -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset -r file.sql DATABASE_NAME
iconv -f utf8 -t cp1252 file.sql | iconv -f cp1251 -t utf8 | sed -e 's/latin1/utf8/g' > file-utf8.sql
mysql --user=USERNAME -p --execute="DROP DATABASE DATABASE_NAME; CREATE DATABASE DATABASE_NAME CHARACTER SET utf8 COLLATE utf8_general_ci;"
mysql --user=USERNAME --max_allowed_packet=16M -p --default-character-set=utf8 DATABASE_NAME < file-utf8.sql
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question