|
我安装你提供的脚本做的实验,结论是可以,贴出详细步骤,供你参考:
mysql> use pubdb;
Database changed
mysql> CREATE TABLE `type` (
-> `id` int(10) unsigned NOT NULL auto_increment,
-> `type_name` varchar(50) character set utf8 NOT NULL default '',
-> PRIMARY KEY (`id`)
-> ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql> show create table type;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| type | CREATE TABLE `type` (
`id` int(10) unsigned NOT NULL auto_increment,
`type_name` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> set names utf8; ----此时可以不用管my.cnf配置文件中是否配置了字符集,默认即可。
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like "%char%" ;
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)
mysql> INSERT INTO type(type_name)value('中文');
Query OK, 1 row affected (0.00 sec)
mysql> select * from type;
+----+-----------+
| id | type_name |
+----+-----------+
| 6 | 中文 |
+----+-----------+
1 row in set (0.00 sec) |
|