MySQL - 使用 unicode 执行文本文件会导致 "question marks"

标签 mysql unicode

表:

CREATE TABLE test (test VARCHAR(10));

test.sql:

INSERT INTO test VALUES ('тест');

在bash中:

$ mysql --version
mysql  Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (x86_64) using readline 6.2
$ file -bi test.sql
text/plain; charset=utf-8
$ mysql --database=... --user=... -p --default-character-set=utf8 < test.sql

结果

mysql> select * from test;
+------+
| test |
+------+
| ???? |
+------+

如何正确执行test.sql

最佳答案

尝试使用 utf8 作为表本身的默认字符集,这样您就不会使用某种默认的拉丁编码。

CREATE TABLE test (test VARCHAR(10)) DEFAULT CHARSET=UTF8;

关于MySQL - 使用 unicode 执行文本文件会导致 "question marks",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16637179/

相关文章:

mysql - 从范围自动插入值到表

mysql - Laravel Eloquent - undefined variable

php - MySQL Match ...反对查询非常慢

language-agnostic - 检测 rtf 标记中的多字节和汉字

c - 如何将代码点 32 位整数数组(UTF-32?)转换为 Windows native 字符串?

html - 增加 Unicode 字符 'BULLET OPERATOR' (U+2219) 的大小

mysql - 自动更新数据库列

PHP 按最大日期到最小日期对添加日期进行排序

iphone - UITextField 使用什么字符作为 secureEntry?

python - 如何使用 Python 从 U+0043 转换为 C?