mysql 字符编码问题

3 views
Skip to first unread message

Lemon

unread,
May 31, 2010, 2:32:40 AM5/31/10
to fedo...@googlegroups.com
原来的一个实验室的小管理系统,数据是用gb2312录入的,现在想导出数据用于另外一个数据库。可是不论从终端登录还是phpmyadmin登录都是乱码,有没有解决方案?

--
There are only 10 types of people in the world, those who understand binary and those who don't.


cheng chen

unread,
May 31, 2010, 5:39:26 AM5/31/10
to fedo...@googlegroups.com, Fedora Chinese
2010/5/31 Lemon <lemo...@gmail.com>

原来的一个实验室的小管理系统,数据是用gb2312录入的,现在想导出数据用于另外一个数据库。可是不论从终端登录还是phpmyadmin登录都是乱码,有没有解决方案?


如果用语言的api的话好像是连接数据库以后加一句:“mysql_query("set names gb2312")”
如果是导入导出你看看表的编码集对不对:
比如:

CREATE DATABASE `bankmanage` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `bankmanage`;

CREATE TABLE IF NOT EXISTS `account` (
  `aid` bigint(11) NOT NULL AUTO_INCREMENT,
  `uid` varchar(20) NOT NULL,
  `password` varchar(256) NOT NULL,
  `money` bigint(11) NOT NULL DEFAULT '0',
  `create_date` date NOT NULL,
  `lost` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`aid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6222003202100000009 ;
 
--
There are only 10 types of people in the world, those who understand binary
and those who don't.

--
(This is Carbon Copied from legacy mailing list fedo...@googlegroups.com.)
_______________________________________________
Chinese mailing list
Chinese at lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/chinese



--
Cheng(誠)

Fedora User
My Page: http://scienologies.blogspot.com
              http://gnudam.webgarden.com
Fedora Project Contributor -- Ambassador
https://fedoraproject.org/wiki/User:Freakrobot
_______________________________________________
Chinese mailing list
Chinese at lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/chinese

Jiahua Huang

unread,
May 31, 2010, 7:14:41 AM5/31/10
to fedo...@googlegroups.com, Fedora Chinese
导出为 sql 纯文本文件后,
手工修改文件编码,修改 sql 语句里的编码字样,
再做导入。

2010/5/31 Lemon <lemo...@gmail.com>
Reply all
Reply to author
Forward
0 new messages