我正在尝试将包含大量日文汉字字符的表从 SQLite 导入 MySQL。我尝试插入数据的表如下所示:
+--------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+----------+------+-----+---------+-------+
| literal | char(10) | NO | PRI | NULL | |
| grade | int(11) | YES | | NULL | |
| stroke_count | int(11) | YES | | NULL | |
| freq | int(11) | YES | | NULL | |
| jlpt | int(11) | YES | | NULL | |
当我尝试
INSERT INTO main VALUES('',NULL,2,NULL,NULL);
我得到了下一个错误:
mysql>
ERROR 1062 (23000): Duplicate entry '?' for key 'PRIMARY'
And if try to look up that entry i get:
select * from main where literal = '';
+---------+-------+--------------+------+------+
| literal | grade | stroke_count | freq | jlpt |
+---------+-------+--------------+------+------+
| | NULL | 4 | NULL | NULL |
+---------+-------+--------------+------+------+
1 row in set (0.00 sec)
为什么查找''它显示为''?
我认为它可能与 UTF8 编码有关,所以我按照此链接的说明将所有 Db 和表重新配置为 utf8mb4 。
这是mysql的配置:
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
+--------------------------+--------------------+
| Variable_name | Value |
+--------------------------+--------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+--------------------------+--------------------+
在那之后没有任何变化......有什么想法吗?
谢谢
此致