Home > Database > Mysql Tutorial > How Can I Recover Damaged UTF-8 Encoding in MySQL?

How Can I Recover Damaged UTF-8 Encoding in MySQL?

Linda Hamilton
Release: 2024-12-14 16:21:11
Original
321 people have browsed it

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:

  1. Create a Dump File:
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
Copy after login
  1. Import the Dump File:
mysql -h DB_HOST -u DB_USER -p DB_PASSWORD \
    --default-character-set=utf8 DB_NAME < DB_NAME-dump.sql
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template