How to Fix Chinese Character Garbling When Migrating Oracle to MySQL
When moving data from Oracle to MySQL, Chinese characters may appear as garbled text because the server uses a latin1 charset; this guide explains three levels of fixes—table, database, and server—by configuring UTF‑8 settings and verifying the changes.
During an Oracle‑to‑MySQL migration, imported Chinese text showed as garbled characters. The client charset was correct, but the MySQL server was still using a latin1 charset, which cannot store Chinese characters.
Solution Levels
Table‑level configuration
Database‑level configuration
Server‑level configuration
Test Environment
Windows Server 2008 R2 with MySQL Community Server 5.7.16. A test database hoegh was created; its default charset was latin1.
1. Table‑level Fix
Create a table without specifying charset; insertion of a Chinese record fails because the table inherits latin1.
Recreate the table with DEFAULT CHARSET=utf8 and insert both English and Chinese rows successfully.
2. Database‑level Fix
Recreate the database with CHARACTER SET=utf8, then create the table (still latin1 by default) and insert records; the database charset overrides the table charset, allowing Chinese text.
3. Server‑level Fix
Check the global variable character_set_server; it is latin1. Modify my.ini to set the server charset to UTF‑8.
default-character-set=utf8
[mysqld]
max_connections=200
default-storage-engine=INNODB
basedir=E:\mysql-5.7.16-winx64\bin
datadir=E:\mysql-5.7.16-winx64\data
port=3306
autocommit=0
character-set-server=utf8Note: default-character-set=utf8 affects the client, while character-set-server=utf8 changes the server.
After restarting MySQL, character_set_server shows utf8.
Recreate the test database and table; insertion and queries work without errors.
Conclusion
All three methods resolve the garbled Chinese characters, but configuring the server charset via my.ini provides a permanent solution. It is strongly recommended to use UTF‑8 (the universal charset) for MySQL deployments.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
