Mysql语句报错: Incorrect string value: for column ‘room_type‘ at row 1

当你执行MySqlt插入含中文内容时,出现Error Code: 1366. Incorrect string value: '\xE6\x80\xBB\xE7\xBB\x9F...' for column 'room_type' at row 1    0.000 sec

检查发现自己字段使用 varchar类型的也使用英文状态下的单引号或双引号了啊,而且创建表也没问题

create table hotel_room(
	room_number varchar(12) not null comment'房间号',
    room_type_id int(11) not null comment'房间类型id',
    primary key(room_number) USING BTREE
)comment'房间表';

可就是在插入语句的时候报错,怎么解决呢,看代码:

create table hotel_room(
	room_number varchar(12) not null comment'房间号',
    room_type_id int(11) not null comment'房间类型id',
    primary key(room_number) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment'房间表';

 加上这句DEFAULT CHARSET=utf8,将编码格式改为UTF-8就可以了,快去试试吧。

猜你喜欢

转载自blog.csdn.net/qq_53376718/article/details/127794344