Home >Database >Mysql Tutorial >How Can I Recover Damaged UTF-8 Encoding in MySQL?
Recovering Damaged UTF-8 Encoding
When encountering corrupted UTF-8 encodings, such as "î," troubleshooting can be challenging. To address this issue, consider the following solution:
For MySQL databases with damaged UTF-8 characters (e.g., accented characters), execute the following steps:
mysqldump -h DB_HOST -u DB_USER -p DB_PASSWORD --opt --quote-names \ --skip-set-charset --default-character-set=latin1 DB_NAME > DB_NAME-dump.sql
mysql -h DB_HOST -u DB_USER -p DB_PASSWORD \ --default-character-set=utf8 DB_NAME < DB_NAME-dump.sql
Note: These steps will convert the character set to latin1 during the dump process and back to utf8 during the import, which rectifies the encoding issues.
Source:
http://blog.hno3.org/2010/04/22/fixing-double-encoded-utf-8-data-in-mysql/
The above is the detailed content of How Can I Recover Damaged UTF-8 Encoding in MySQL?. For more information, please follow other related articles on the PHP Chinese website!