/ 中存储网

MySQL客户端的编码设置

2014-07-13 15:42:18 来源:中存储网

Microsoft Windows XP [版本 5.1.2600]

(C) 版权所有 1985-2001 Microsoft Corp.

C:Documents and SettingsAdministrator>mysql -uroot -p19831993
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.0.67-community-nt MySQL Community Edition (GPL)

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> use mytest;
Database changed
mysql> show tables;
+------------------+
| Tables_in_mytest |
+------------------+
| hibernate02      |
| t_info           |
| t_info2          |
| t_organization   |
+------------------+
4 rows in set (0.01 sec)

mysql> desc hibernate02;
+----------+--------------+------+-----+---------+----------------+
| Field    | Type         | Null | Key | Default | Extra          |
+----------+--------------+------+-----+---------+----------------+
| id       | int(11)      | NO   | PRI | NULL    | auto_increment |
| username | varchar(255) | YES  |     | NULL    |                |
| userpwd  | varchar(255) | YES  |     | NULL    |                |
| sex      | varchar(255) | YES  |     | NULL    |                |
| email    | varchar(255) | YES  |     | NULL    |                |
+----------+--------------+------+-----+---------+----------------+
5 rows in set (0.03 sec)

mysql> create table johnTest as select * from hibernate02;
Query OK, 4 rows affected (0.05 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> show tables;
+------------------+
| Tables_in_mytest |
+------------------+
| hibernate02      |
| johntest         |
| t_info           |
| t_info2          |
| t_organization   |
+------------------+
5 rows in set (0.00 sec)

mysql> desc johntest
    -> ;
+----------+--------------+------+-----+---------+-------+
| Field    | Type         | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| id       | int(11)      | NO   |     | 0       |       |
| username | varchar(255) | YES  |     | NULL    |       |
| userpwd  | varchar(255) | YES  |     | NULL    |       |
| sex      | varchar(255) | YES  |     | NULL    |       |
| email    | varchar(255) | YES  |     | NULL    |       |
+----------+--------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> select * from johntest;
+----+----------+-----------+------+----------------------+
| id | username | userpwd   | sex  | email                |
+----+----------+-----------+------+----------------------+
|  1 | 寮犱笁     | 19831993  | 鐢?  | phper@163.com        |
|  2 | 寮犻     | qazxsw    | 濂?  | phperlove@163.com    |
|  3 | 澶у湴     | ikf;ajf;a | 濂?  | lovephysivcs@163.com |
|  4 | 寮犳枃     | gsgfsfsd  | 鐢?  | NULL                 |
+----+----------+-----------+------+----------------------+
4 rows in set (0.00 sec)
mysql> set character_set_results='gbk';
Query OK, 0 rows affected (0.00 sec)

mysql> select * from johntest;
+----+----------+-----------+------+----------------------+
| id | username | userpwd   | sex  | email                |
+----+----------+-----------+------+----------------------+
|  1 | 张三         | 19831993  | 男     | phper@163.com        |
|  2 | 张飞        | qazxsw    | 女    | phperlove@163.com    |
|  3 | 大地         | ikf;ajf;a | 女    | lovephysivcs@163.com |
|  4 | 张文         | gsgfsfsd  | 男     | NULL                 |
+----+----------+-----------+------+----------------------+
4 rows in set (0.27 sec)

mysql>