阿郎的技术搏客

成长轨迹

mysql4.1以上数据库的中文字符集的解决

mysql4.1以上数据库的中文字符集的解决

在进入mysql控制台后,用如下命令中设置字符集:
SET character_set_client=utf8
SET character_set_connection=utf8
SET character_set_database=utf8
SET character_set_results=utf8
SET character_set_server=utf8
SET collation_connection=utf8_bin
SET collation_database=utf8_bin
SET collation_server=utf8_bin

也可以在my.ini中的[mysql]中
CREATE DATABASE yourdatabasename
       CHARACTER SET utf8
       DEFAULT CHARACTER SET utf8
       COLLATE utf8_general_ci
       DEFAULT COLLATE utf8_general_ci ;

mysql YourDatabaseName <**.sql
对于mysql命令导入mysql 数据库的sql文件,需要加入参数:
--default-character-set=utf8 YourDatabaseName


mysql>  show   variables   like   "%char%";
| Variable_name            | Value                                  |
| character_set_client     | latin1                                 |
| character_set_connection | latin1                                 |
| character_set_database   | utf8                                   |
| character_set_results    | latin1                                 |
| character_set_server     | utf8                                   |
| character_set_system     | utf8                                   |
| character_sets_dir       | C:\your mysql home\share\charsets/ |
7 rows in set (0.00 sec)

show   variables   like   "%col%";
| Variable_name        | Value             |
| collation_connection | latin1_swedish_ci |
| collation_database   | utf8_general_ci   |
| collation_server     | utf8_general_ci   |
| protocol_version     | 10                |
4 rows in set (0.00 sec)

从4.0到4.1以上数据库的迁移问题的解决。
用mysqldump 命令将数据库导出4.0(-)的数据库后,在4.1(+)的数据库指定导入文件的字符集,即可。
mysqldump –p –where="Order_ID > 2000" Meet_A_Geek Orders > Special_Dump.txt
mysql --default-character-set=utf8 YourDatabaseName <preffixtemplate_block_history.sql

 

posted on 2007-04-17 14:57 alone 阅读(473) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: