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;