• ERROR 1366 (HY000): Incorrect string value: 'xD5xC5xC8xFD' for column 'name' at row 1


    ERROR 1366 (HY000): Incorrect string value: 'xD5xC5xC8xFD' for column 'name'

     at row 1
     
    数据库字符集问题,查看数据库状态:
    mysql> status;
    --------------
    mysql  Ver 14.14 Distrib 5.6.12, for Win32 (x86)
     
    Connection id:          25
    Current database:       information_schema
    Current user:           root@localhost
    SSL:                    Not in use
    Using delimiter:        ;
    Server version:         5.6.12 MySQL Community Server (GPL)
    Protocol version:       10
    Connection:             localhost via TCP/IP
    Server characterset:    latin1
    Db     characterset:    latin1
    Client characterset:    gbk
    Conn.  characterset:    gbk
    TCP port:               3306
    Uptime:                 8 hours 54 min 47 sec
     
    Threads: 1  Questions: 372  Slow queries: 0  Opens: 108  Flush tables: 1  Open t
    ables: 62  Queries per second avg: 0.011
    --------------
    我要使用的库test的字符集是latin1,该字符集不支持中文字符。
    查看表引擎状态:
    mysql> show create table ttt;
    +-------+-----------------------------------------------------------------------
    -----------------------------------------------------------------------+
    | Table | Create Table
                                                                          |
    +-------+-----------------------------------------------------------------------
    -----------------------------------------------------------------------+
    | ttt   | CREATE TABLE `ttt` (
      `id` int(11) NOT NULL,
      `name` varchar(20) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
    +-------+-----------------------------------------------------------------------
    -----------------------------------------------------------------------+
    修改表字符集:
    mysql> alter table ttt character set utf8;
    Query OK, 0 rows affected (0.10 sec)
    Records: 0  Duplicates: 0  Warnings: 0
     
    mysql> show create table ttt;
    +-------+-----------------------------------------------------------------------
    --------------------------------------------------------------------------------
    ----------+
    | Table | Create Table
     
              |
    +-------+-----------------------------------------------------------------------
    --------------------------------------------------------------------------------
    ----------+
    | ttt   | CREATE TABLE `ttt` (
      `id` int(11) NOT NULL,
      `name` varchar(20) CHARACTER SET latin1 DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
    +-------+-----------------------------------------------------------------------
    --------------------------------------------------------------------------------
    ----------+
    修改字段字符集:
    mysql> alter table ttt modify name varchar(20) character set utf8;
    Query OK, 0 rows affected (1.01 sec)
    Records: 0  Duplicates: 0  Warnings: 0
     
    mysql> show create table ttt;
    +-------+-----------------------------------------------------------------------
    ---------------------------------------------------------------------+
    | Table | Create Table
                                                                        |
    +-------+-----------------------------------------------------------------------
    ---------------------------------------------------------------------+
    | ttt   | CREATE TABLE `ttt` (
      `id` int(11) NOT NULL,
      `name` varchar(20) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
    +-------+-----------------------------------------------------------------------
    ---------------------------------------------------------------------+
    1 row in set (0.02 sec)
     
    OK!
    转载出处   http://blog.sina.com.cn/s/blog_8f7940400101by3u.html
  • 相关阅读:
    转自 陈皓 博客 《提高效率》
    codevs 1098 均分纸牌 2002年NOIP全国联赛提高组 x
    codevs 1160 蛇形矩阵x
    【説明する】进制转换
    欧几里得?x
    codevs 1020 孪生蜘蛛 x
    [HDOJ5883]The Best Path(欧拉回路,异或)
    [HDOJ5889]Barricade(spfa,最大流)
    [PAT L2-001] 紧急救援(spfa,最短路计数, dp)
    [CF717E]Paint it really, really dark gray(dfs,构造)
  • 原文地址:https://www.cnblogs.com/seven-ahz/p/7083372.html
Copyright © 2020-2023  润新知