欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

mysql4.0升级到mysql5(4.1),解决字符集问题

程序员文章站 2023-12-13 15:11:34
1、从4.0中导出表 mysqldump –no-data -uroot -p database > struct.sql 2、导出数据 mysqldump –no-...
1、从4.0中导出表 mysqldump –no-data -uroot -p database > struct.sql
2、导出数据 mysqldump –no-create-info=true –extended-insert=false -u root -p database > data.sql
3、用vi编辑struct.sql, 使用最末行命令
:%s/) type=myisam;/) engine=myisam default charset=gbk;/g
:%s/) type=heap.*$/) engine=memory default charset=gbk;/g

4、导入struct.sql,data.sql

mysql 4.0及之前的版本,都是只支持一种字符集latin1,从mysql 4.1起,支持众多的字符集,比如gbk,utf8(非utf-8)等。
gbk,utf8等多字节字符集的存储也发生了变化,比如latin1下,汉字字长是2,在gbk或utf8下,汉字字长就是1。也就是说原来varchar(32)只能存16个汉字,现在能保存32个了。

网址:

上一篇:

下一篇: