安装了MySQL 5.0.26(默认字符集utf-8(个人认为应该是字符编码))之后,运行MySQL Command Line Client,输入密码后,信息如下:
Enter password: *******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.26-community-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
在提示符后输入:SET NAMES gbk; (如果安装MySQL选择了默认字符集是gbk就不用这一步)
然后建表(参考MySQL5.1 参考手册3.6.9)
mysql> SET NAMES gbk;
Query OK, 0 rows affected (0.00 sec)
mysql> use test
Database changed
mysql> CREATE TABLE animals(
-> id MEDIUMINT NOT NULL AUTO_INCREMENT,
-> name VARCHAR(5) NOT NULL,
-> PRIMARY KEY (id)
-> );
Query OK, 0 rows affected (0.19 sec)
mysql> INSERT INTO animals (name) VALUES
-> ('鼠'),('牛'),('虎'),('兔'),('龙'),('蛇'),
-> ("马"),("羊"),("猴"),("鸡"),("狗"),("猪");
Query OK, 12 rows affected (0.05 sec)
Records: 12 Duplicates: 0 Warnings: 0
mysql> SELECT * FROM animals;
+----+------+
| id | name |
+----+------+
| 1 | 鼠 |
| 2 | 牛 |
| 3 | 虎 |
| 4 | 兔 |
| 5 | 龙 |
| 6 | 蛇 |
| 7 | 马 |
| 8 | 羊 |
| 9 | 猴 |
| 10 | 鸡 |
| 11 | 狗 |
| 12 | 猪 |
+----+------+
12 rows in set (0.01 sec)