MYSQL不能显示中文字,显示错误“ERROR 1366 (HY000): Incorrect string value: '\xE5\xBC\xA0\xE4\xB8\x89'”

或者建表时带上编码utf8

CREATE TABLE `students`(
    `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `name` VARCHAR(20) NOT NULL,
    `nickname` VARCHAR(20) NULL,
    `sex` CHAR(1) NULL,
    `in_time` DATETIME NULL
   ) DEFAULT CHARSET 'utf8';

或者修改table的编码:

alter table students convert to character set utf8;

如果仍有编码不是utf8的,请检查配置文件,也可使用mysql命令设置:

set character_set_client = utf8;
set character_set_server = utf8;
set character_set_connection = utf8;
set character_set_results = utf8;
set collation_connection = utf8_general_ci;
set collation_database = utf8_general_ci;
set collation_server = utf8_general_ci;
posted @ 2018-12-20 20:11  cicarius  阅读(2768)  评论(0编辑  收藏  举报