在cmd里运行mysql,显示中文乱码

2024-12-17 18:48:16
推荐回答(2个)
回答1:

charset gbk;

使用charset命令即可,

mysql> charset utf8;
Charset changed
mysql> select * from tb_ddz;
+-----------+-----------------+------+---------------------------+------+------+-------+
| ip        | nick            | sex  | imgsrc                    | win  | lose | score |
+-----------+-----------------+------+---------------------------+------+------+-------+
| 127.0.0.1 | 鐢?鐢?          | man  | img/DMPhotoBk.png         | 0    | 0    | 100   |
| 127.0.0.2 | 姝﹁棨娓告垙        | man  | photo/姝﹁棨娓告垙.png        | 0    | 0    | 100   |
| 127.0.0.3 | 娴烽┈璧栦汉        | man  | photo/娴烽┈璧栦汉.png        | 0    | 0    | 100   |
| 127.0.0.4 | 鍩庝箣鍐呭厕涔?     | man  | photo/鍩庝箣鍐呭厕涔?png      | 0    | 0    | 100   |
+-----------+-----------------+------+---------------------------+------+------+-------+
4 rows in set (0.06 sec)

mysql> charset gbk;
Charset changed
mysql> select * from tb_ddz;
+-----------+------------+------+----------------------+------+------+-------+
| ip        | nick       | sex  | imgsrc               | win  | lose | score |
+-----------+------------+------+----------------------+------+------+-------+
| 127.0.0.1 | 男 生      | man  | img/DMPhotoBk.png    | 0    | 0    | 100   |
| 127.0.0.2 | 武藤游戏   | man  | photo/武藤游戏.png   | 0    | 0    | 100   |
| 127.0.0.3 | 海马赖人   | man  | photo/海马赖人.png   | 0    | 0    | 100   |
| 127.0.0.4 | 城之内克也 | man  | photo/城之内克也.png | 0    | 0    | 100   |
+-----------+------------+------+----------------------+------+------+-------+
4 rows in set (0.00 sec)

mysql>

回答2:

这个你jboss运行环境不是utf-8