我想将一些中文字符导入MySQL数据库。但有些内容被省略,有些内容显示无意义。如下图所示:
数据库中有什么:
excel文件中有什么:
谢谢!
嗨,这是附加信息:
文本文件
巴掌 bāzhang (a slap of the) palm 打 beat human activities
巴掌 bāzhang (a slap of the) palm 搧 spank human activities
巴掌 bāzhang (a slap of the) palm 揍 hit human activities
把 bá tools and objects with a handle 扫帚 broom tools
把 bá tools and objects with a handle 锁 lock man-made
show create table
CREATE TABLE `table 1` (
`CL_in_Character` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
`CL_in_Pinyin` varchar(14) CHARACTER SET utf8 DEFAULT NULL,
`Definition_in_Dictionary` varchar(74) CHARACTER SET utf8 DEFAULT NULL,
`Associated_nouns_in_Chinese` varchar(16) CHARACTER SET utf8 DEFAULT NULL,
`Associated_nouns_in_English` varchar(38) CHARACTER SET utf8 DEFAULT NULL,
`Associated_noun_categories` varchar(38) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
答案 0 :(得分:2)
我无法分辨开放文档格式和phpmyadmin,但您可以使用
成功导入格式正确的CSV格式的数据LOAD DATA INFILE '/path/to/your/file.csv' INTO TABLE `table 1`
CHARACTER SET 'utf8'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
通过格式化为CSV,我的意思是
CL_in_Character,CL_in_Pinyin,Definition_in_Dictionary,Associated_nouns_in_Chinese,Associated_nouns_in_English,Associated_noun_categories "巴掌","bāzhang","(a slap of the) palm","打","beat","human activities" "巴掌","bāzhang","(a slap of the) palm","搧","spank","human activities" "巴掌","bāzhang","(a slap of the) palm","揍","hit","human activities" "把","bá","tools and objects with a handle","扫帚","broom","tools" "把","bá","tools and objects with a handle","锁","lock","man-made"
我们试试吧
mysql> CREATE TABLE `table 1` ( -> `CL_in_Character` varchar(10) CHARACTER SET utf8 DEFAULT NULL, -> `CL_in_Pinyin` varchar(14) CHARACTER SET utf8 DEFAULT NULL, -> `Definition_in_Dictionary` varchar(74) CHARACTER SET utf8 DEFAULT NULL, -> `Associated_nouns_in_Chinese` varchar(16) CHARACTER SET utf8 DEFAULT NULL, -> `Associated_nouns_in_English` varchar(38) CHARACTER SET utf8 DEFAULT NULL, -> `Associated_noun_categories` varchar(38) CHARACTER SET utf8 DEFAULT NULL -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; Query OK, 0 rows affected (0.03 sec) mysql> LOAD DATA INFILE '/tmp/utf.csv' INTO TABLE `table 1` -> CHARACTER SET 'utf8' -> FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' -> LINES TERMINATED BY '\n' -> IGNORE 1 LINES; Query OK, 5 rows affected (0.00 sec) Records: 5 Deleted: 0 Skipped: 0 Warnings: 0 mysql> select * from `table 1`; +-----------------+--------------+---------------------------------+-----------------------------+-----------------------------+----------------------------+ | CL_in_Character | CL_in_Pinyin | Definition_in_Dictionary | Associated_nouns_in_Chinese | Associated_nouns_in_English | Associated_noun_categories | +-----------------+--------------+---------------------------------+-----------------------------+-----------------------------+----------------------------+ | 巴掌 | bāzhang | (a slap of the) palm | 打 | beat | human activities | | 巴掌 | bāzhang | (a slap of the) palm | 搧 | spank | human activities | | 巴掌 | bāzhang | (a slap of the) palm | 揍 | hit | human activities | | 把 | bá | tools and objects with a handle | 扫帚 | broom | tools | | 把 | bá | tools and objects with a handle | 锁 | lock | man-made | +-----------------+--------------+---------------------------------+-----------------------------+-----------------------------+----------------------------+ 5 rows in set (0.00 sec)
答案 1 :(得分:0)
我遇到了和你一样的问题并且达到了这个问题。然后我通过改变phpmyadmin中的选项来解决它
Lines terminated with: auto
到
Lines terminated with: \n
答案 2 :(得分:0)
我通过复制整个excel数据解决了这个问题,并粘贴为值,然后它将识别该字符。