Today, I export a file from windows. the SQL file is expected to be imported to linux's unbutn again. Next I will introduce you to some friends who need to know how to import Chinese garbled characters in source.
Error Message
All Chinese characters are garbled.
Solution
Query mysql settings
Mysql> s
--------------
C: Program FilesMySQLMySQL Server 5.0binmysql.exe Ver 14.12 Distrib 5.0.67,
For Win32 (ia32)
Connection id: 1
Current database: common
Current user: root @ localhost
SSL: Not in use
Using delimiter :;
Server version: 5.0.67-community-nt MySQL Community Edition (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 1 min 23 sec
Threads: 1 Questions: 14 Slow queries: 0 Opens: 13 Flush tables: 1 Open tab
Les: 7 Queries per second avg: 0.169
When exporting the mysql SQL Execution file, specify the encoding format:
The Code is as follows: |
Copy code |
Mysqldump-uroot-p -- default-character-set = utf8 mo (dbname)> E: // xxxx. SQL |
The import is OK.
Run the following command:
The Code is as follows: |
Copy code |
Mysql-u root-p -- default-character-set = utf8 Use dbname Source/root/newsdata. SQL |
Note: If you are using gbk, we only need to set it to gbk. It depends on the database code found above.