本帖最后由 wbliang2011 于 2012-12-30 18:10:23 编辑

解决方案 »

  1.   

    client,
    server
    results
    要一致
    推荐你就使用utf8
      

  2.   

    按下贴中方法贴出你的检查结果。 直接贴文本即可不必贴图。http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/12/4174186.aspx
    MySQL 中文显示乱码
      

  3.   

    mysql> show variables like '%char%';
    +--------------------------+----------------------------------------------------
    -----+
    | Variable_name            | Value
         |
    +--------------------------+----------------------------------------------------
    -----+
    | character_set_client     | utf8
         |
    | character_set_connection | utf8
         |
    | character_set_database   | utf8
         |
    | character_set_filesystem | binary
         |
    | character_set_results    | utf8
         |
    | character_set_server     | utf8
         |
    | character_set_system     | utf8
         |
    | character_sets_dir       | C:\Program Files\MySQL\MySQL Server 5.5\share\chars
    ets\ |
    +--------------------------+----------------------------------------------------
    -----+
    8 rows in set (0.00 sec)mysql> select name from player where id=100001;
    +---------------+
    | name          |
    +---------------+
    | 濞撶?100001   |
    +---------------+
    1 row in set (0.03 sec)
    已经一致啦,可还是显示乱码
      

  4.   

    mysql> show create table player;
    +--------+----------------------------------------------------------------------
    -----------------------------------------------------+
    | Table  | Create Table
                                               |
    +--------+----------------------------------------------------------------------
    -----------------------------------------------------+
    | player | CREATE TABLE `player` (
      `Id` int(11) NOT NULL AUTO_INCREMENT,
      `name` varchar(50) NOT NULL DEFAULT '',
      `account_id` int(11) NOT NULL DEFAULT '0',
      `account_name` varchar(50) NOT NULL DEFAULT '',
      PRIMARY KEY (`Id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=1838561 DEFAULT CHARSET=utf8 |
    +--------+----------------------------------------------------------------------
    -----------------------------------------------------+
    1 row in set (0.08 sec)
    还有上面的
      

  5.   


    mysql> use test;
    Database changed
    mysql> show create table player;
    +--------+----------------------------------------------------------------------
    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------
    -----------------------------------------------------+
    | Table  | Create Table
                                                         |
    +--------+----------------------------------------------------------------------
    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------
    -----------------------------------------------------+
    | player | CREATE TABLE `player` (
      `Id` int(11) NOT NULL AUTO_INCREMENT,
      `name` varchar(50) NOT NULL DEFAULT '',
      `account_id` int(11) NOT NULL DEFAULT '0',
      `account_name` varchar(50) NOT NULL DEFAULT '',
      PRIMARY KEY (`Id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=1838561 DEFAULT CHARSET=utf8 |
    +--------+----------------------------------------------------------------------
    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------
    -----------------------------------------------------+
    1 row in set (0.08 sec)mysql> show full columns from player;
    +--------------+-------------+-----------------+------+-----+---------+---------
    -------+---------------------------------+---------+
    | Field        | Type        | Collation       | Null | Key | Default | Extra
           | Privileges                      | Comment |
    +--------------+-------------+-----------------+------+-----+---------+---------
    -------+---------------------------------+---------+
    | Id           | int(11)     | NULL            | NO   | PRI | NULL    | auto_inc
    rement | select,insert,update,references |         |
    | name         | varchar(50) | utf8_general_ci | NO   |     |         |
           | select,insert,update,references |         |
    | account_id   | int(11)     | NULL            | NO   |     | 0       |
           | select,insert,update,references |         |
    | account_name | varchar(50) | utf8_general_ci | NO   |     |         |
           | select,insert,update,references |         |
    +--------------+-------------+-----------------+------+-----+---------+---------
    -------+---------------------------------+---------+
    4 rows in set (0.03 sec)

      

  6.   

    先 
    set names 'gbk';
    insert into player (name) values ('楼主');
    select * from player where ....看一下你的结果是否正常,如果正常,则说明之前插入到表中的记录中的编码不对。需要人工修正。
      

  7.   


    的确是这个问题,可以正常显示,但是要怎么修改呢?我把 player.sql文件中的 DEFAULT CHARSET=utf8 改成 gbk 后输出没有问题,但为什么utf8就不行呢?

    DROP TABLE IF EXISTS `player`;
    CREATE TABLE `player` (
      `Id` int(11) NOT NULL AUTO_INCREMENT,
      `name` varchar(50) NOT NULL DEFAULT '',
      `account_id` int(11) NOT NULL DEFAULT '0',
      `account_name` varchar(50) NOT NULL DEFAULT '',
      PRIMARY KEY (`Id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=1838561 DEFAULT CHARSET=utf8;#
    # Dumping data for table player
    #INSERT INTO `player` VALUES (100001,'游客100001',100001,'guest100001');
    INSERT INTO `player` VALUES (100012,'游客100012',100012,'guest100012');
    INSERT INTO `player` VALUES (100016,'游客100016',100016,'guest100016');

      

  8.   

    因为WINDOWS的命令行CMD无法有效的支持UTF8