mySql 插入中文异常 Incorrect string value: '***' for column

问题是由mysql的编码问题造成

  1.首先考虑是否是mysql编码的问题

    查看mysql的字符集:show variables where Variable_name like '%char%';

    修改mysql的字符集:   

      mysql> set character_set_client=utf8;

                mysql> set character_set_connection=utf8;

                mysql> set character_set_database=utf8;

                mysql> set character_set_results=utf8;

                mysql> set character_set_server=utf8;

                mysql> set character_set_system=utf8;

                mysql> set collation_connection=utf8;

                mysql> set collation_database=utf8;

                mysql> set collation_server=utf8;

  2.是否是数据库编码的问题

    查看数据库的字符集:show create database enterprises;

    修改数据库的字符集:alter database enterprises character set utf8

  3.是否是表的编码问题

    查看表的字符集:show create table employees;(位于建表语句的末尾)

    修改表的字符集:alter table employees character set utf8

    修改字段的字符集:alter table employees change name name char(10) character set utf-8;

上一篇:MySql报错:1366-incorrect string value:'\xE8\x80\x8c\xE6\x88\x91' for column 'titl


下一篇:Mysql插入中文时提示:ERROR 1366 (HY000): Incorrect string value: '\xE5\x8F\xB0\xE5\xBC\x8F...