怎么在MYsql中输入中文字符?急急急急……

解决方案 »

  1.   

    中文可以直接输入。 不过要注意字符集的设置。创建表的时候看一下字符集是不是 中文。使用的时候注意用命令 set names 'gbk'; 设置一下联接的字符集。http://dev.mysql.com/doc/refman/5.1/zh/charset.html
      

  2.   

    在C:\Program Files\MySQL\MySQL Server 5.0\my.ini中设置:
    [mysql]
    default-character-set=gb2312
    # 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="C:/Program Files/MySQL/MySQL Server 5.0/"#Path to the database root
    datadir="C:/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# The default storage engine that will be used when create new tables when
    default-storage-engine=INNODB# Set the SQL mode to strict
    # sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
      

  3.   

    MySQL Command line Client界面无法显示中文?
      

  4.   

    怎么看字符集? mysql> show variables like 'char%';
    +--------------------------+---------------------------------------------------------+
    | Variable_name            | Value     |
    +--------------------------+---------------------------------------------------------+
    | character_set_client     | latin1     |
    | character_set_connection | latin1     |
    | character_set_database   | latin1     |
    | character_set_filesystem | binary     |
    | character_set_results    | latin1     |
    | character_set_server     | latin1     |
    | character_set_system     | utf8     |
    | character_sets_dir       | C:\Program Files\MySQL\MySQL Server 5.1\share\charsets\ |
    +--------------------------+---------------------------------------------------------+
    8 rows in set (0.00 sec)mysql> show full columns from t;
    +--------------+------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
    | Field        | Type       | Collation         | Null | Key | Default | Extra | Privileges                      | Comment |
    +--------------+------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
    | id           | int(11)    | NULL              | NO   | PRI | NULL    |       | select,insert,update,references |         |
    | name         | varchar(5) | latin1_swedish_ci | YES  |     | NULL    |       | select,insert,update,references |         |
    | score        | int(11)    | NULL              | YES  |     | NULL    |       | select,insert,update,references |         |
    | mapping_name | varchar(5) | latin1_swedish_ci | YES  |     | NULL    |       | select,insert,update,references |         |
    | flag         | tinyint(1) | NULL              | YES  |     | NULL    |       | select,insert,update,references |         |
    +--------------+------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
    5 rows in set (0.02 sec)
    mysql>set names 'gb2312';1. 确保你表中的字段是中文字符集(gb2312 , gbk, utf8 均可 )
    2. 确保你联接中使用的字符集与表中的相同。 可以按 tyuiouio  所说的,在my.ini中把整个MySQL的服务的默认字符集设置为 gb2312, 这样以后你创建的表的默认字符集就是gb2312 了,但之前已经输入的表,需要导出现导入以更新字符集设置。这些问题在MySQL的官方文档中已经有详细说明,建议你先花10分钟浏览一篇。
    http://dev.mysql.com/doc/refman/5.1/zh/charset.html