我装MYSQL时选的字符集是utf8
test表中只有一个字段varchar(20)类型,
insert into test values ('中文');
在控制台中执行会报错:无效的字符值。
请问这是为什么?

解决方案 »

  1.   

     修改my.ini文件的字符集为gbk,然后重启服务再插入试试。
      

  2.   

    问一个很小白的问题,my.ini在哪里啊?我在MySQL Administrator   和 Query里怎么没找到啊?
    麻烦指点一下,谢谢。
      

  3.   

    在你装的MySQL\MySQL Server 5.0的目录下.里面有my的配置设置.
      

  4.   

    # ----------------------------------------------------------------------
    #
    # The following options will be read by MySQL client applications.
    # Note that only client applications shipped by MySQL are guaranteed
    # to read this section. If you want your own MySQL client program to
    # honor these values, you need to specify it as an option during the
    # MySQL client library initialization.
    #
    [client]port=3306[mysql]default-character-set=latin1
    # SERVER SECTION
    # ----------------------------------------------------------------------不知道是不是这个.
      

  5.   

    show variables like 'char%'; 
    贴结果
      

  6.   

    建议utf8
    [client]port=3306[mysql]default-character-set=utf8
    # SERVER SECTION
    # ----------------------------------------------------------------------
    #
    # The following options will be read by the MySQL Server. Make sure that
    # you have installed the server correctly (see above) so it reads this 
    # file.
    #
    [mysqld]# The TCP/IP Port the MySQL Server will listen on
    port=3306
    #Path to installation directory. All paths are usually resolved relative to this.
    basedir="D:/Program Files/MySQL/MySQL Server 5.0/"#Path to the database root
    datadir="D:/Program Files/MySQL/MySQL Server 5.0/Data/"# The default character set that will be used when a new schema or table is
    # created and no character set is defined
    default-character-set=utf8你的客户端程序也要使用utf8,一致
      

  7.   

    CSDN的这个编辑器真叫一个烂
    :-))试试看把你的代码添加为 batch 格式或其它格式