有一个 xx.sql 数据库文件,字符集是utf-8的,导入我的mysql就报错,扬声器响个不停。如何将这个文件转换为gbk的字符集 再导入呢?
解决方案 »
- 这样的sql怎么写
- mysql中变量类型
- 请教一个奇怪的mysql问题,大家帮忙看看是不是bug
- 急啊,求救:数据库不能打开了
- mysql从那个版本开始有触发器啊?
- 求一个mysql的sql语句最优写法
- 出现这样的错误是什么原因,服务已启动,用户名密码正确,全句见内Data source rejected establishment of connection, ......to this MySQL
- C中使用MYSQL的问题
- 菜鸟问题:PLSQL DEVELOPER可以在本地使用吗?
- 数据库设计关于关系的确定(求指教)
- 数据库操作中当UPDATE不成功时,我在Insert 出现重复键问题??????
- 表缓存如何优化?
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
导入时,它会自动转换
mysql --default-character-set=utf8 < xxx.sql
# <?exit();?>
#------------------------------------------------
-- Server version 5.0.26-Comsenz-log
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;--
-- Table structure for table `cdb_members`
--DROP TABLE IF EXISTS `cdb_members`;
CREATE TABLE `cdb_members` (
`uid` mediumint(8) unsigned NOT NULL auto_increment,
`username` char(25) default NULL,
`password` char(32) NOT NULL default '',
`secques` char(8) NOT NULL default '',
`gender` tinyint(1) NOT NULL default '0',
`adminid` tinyint(1) NOT NULL default '0',
`groupid` smallint(6) unsigned NOT NULL default '0',
`groupexpiry` int(10) unsigned NOT NULL default '0',
`extgroupids` char(20) NOT NULL default '',
`regip` char(15) NOT NULL default '',
`regdate` int(10) unsigned NOT NULL default '0',
`lastip` char(15) NOT NULL default '',
`lastvisit` int(10) unsigned NOT NULL default '0',
`lastactivity` int(10) unsigned NOT NULL default '0',
`lastpost` int(10) unsigned NOT NULL default '0',
`posts` mediumint(8) unsigned NOT NULL default '0',
`digestposts` smallint(6) unsigned NOT NULL default '0',
`oltime` smallint(6) unsigned NOT NULL default '0',
`pageviews` mediumint(8) unsigned NOT NULL default '0',
`credits` int(10) NOT NULL default '0',
`extcredits1` int(10) NOT NULL default '0',
`extcredits2` int(10) NOT NULL default '0',
`extcredits3` int(10) NOT NULL default '0',
`extcredits4` int(10) NOT NULL default '0',
`extcredits5` int(10) NOT NULL default '0',
`extcredits6` int(10) NOT NULL default '0',
`extcredits7` int(10) NOT NULL default '0',
`extcredits8` int(10) NOT NULL default '0',
`email` char(40) NOT NULL default '',
`bday` date NOT NULL default '0000-00-00',
`sigstatus` tinyint(1) NOT NULL default '0',
`tpp` tinyint(3) unsigned NOT NULL default '0',
`ppp` tinyint(3) unsigned NOT NULL default '0',
`styleid` smallint(6) unsigned NOT NULL default '0',
`dateformat` tinyint(1) NOT NULL default '0',
`timeformat` tinyint(1) NOT NULL default '0',
`pmsound` tinyint(1) NOT NULL default '0',
`showemail` tinyint(1) NOT NULL default '0',
`newsletter` tinyint(1) NOT NULL default '0',
`invisible` tinyint(1) NOT NULL default '0',
`timeoffset` char(4) NOT NULL default '',
`newpm` tinyint(1) NOT NULL default '0',
`accessmasks` tinyint(1) NOT NULL default '0',
`editormode` tinyint(1) unsigned NOT NULL default '2',
`customshow` tinyint(1) unsigned NOT NULL default '26',
`xspacestatus` tinyint(1) NOT NULL default '1',
PRIMARY KEY (`uid`),
UNIQUE KEY `username` (`username`),
KEY `email` (`email`),
KEY `groupid` (`groupid`)
) ENGINE=MyISAM AUTO_INCREMENT=1828024 DEFAULT CHARSET=gbk;--
-- Dumping data for table `cdb_members`
--
mysql> # <?exit();?>
mysql>
mysql> #------------------------------------------------
mysql> -- Server version 5.0.26-Comsenz-log
mysql> /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
Query OK, 0 rows affected (0.00 sec)mysql> /*!40103 SET TIME_ZONE='+00:00' */;
Query OK, 0 rows affected (0.00 sec)mysql> /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 *
Query OK, 0 rows affected (0.00 sec)mysql> /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN
ECKS=0 */;
Query OK, 0 rows affected (0.00 sec)mysql> /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_
/;
Query OK, 0 rows affected (0.00 sec)mysql> /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
Query OK, 0 rows affected (0.00 sec)mysql>
mysql> --
mysql> -- Table structure for table `cdb_members`
mysql> --
mysql>
mysql> DROP TABLE IF EXISTS `cdb_members`;
Query OK, 0 rows affected (0.06 sec)mysql> CREATE TABLE `cdb_members` (
-> `uid` mediumint(8) unsigned NOT NULL auto_increment,
-> `username` char(25) default NULL,
-> `password` char(32) NOT NULL default '',
-> `secques` char(8) NOT NULL default '',
-> `gender` tinyint(1) NOT NULL default '0',
-> `adminid` tinyint(1) NOT NULL default '0',
-> `groupid` smallint(6) unsigned NOT NULL default '0',
-> `groupexpiry` int(10) unsigned NOT NULL default '0',
-> `extgroupids` char(20) NOT NULL default '',
-> `regip` char(15) NOT NULL default '',
-> `regdate` int(10) unsigned NOT NULL default '0',
-> `lastip` char(15) NOT NULL default '',
-> `lastvisit` int(10) unsigned NOT NULL default '0',
-> `lastactivity` int(10) unsigned NOT NULL default '0',
-> `lastpost` int(10) unsigned NOT NULL default '0',
-> `posts` mediumint(8) unsigned NOT NULL default '0',
-> `digestposts` smallint(6) unsigned NOT NULL default '0',
-> `oltime` smallint(6) unsigned NOT NULL default '0',
-> `pageviews` mediumint(8) unsigned NOT NULL default '0',
-> `credits` int(10) NOT NULL default '0',
-> `extcredits1` int(10) NOT NULL default '0',
-> `extcredits2` int(10) NOT NULL default '0',
-> `extcredits3` int(10) NOT NULL default '0',
-> `extcredits4` int(10) NOT NULL default '0',
-> `extcredits5` int(10) NOT NULL default '0',
-> `extcredits6` int(10) NOT NULL default '0',
-> `extcredits7` int(10) NOT NULL default '0',
-> `extcredits8` int(10) NOT NULL default '0',
-> `email` char(40) NOT NULL default '',
-> `bday` date NOT NULL default '0000-00-00',
-> `sigstatus` tinyint(1) NOT NULL default '0',
-> `tpp` tinyint(3) unsigned NOT NULL default '0',
-> `ppp` tinyint(3) unsigned NOT NULL default '0',
-> `styleid` smallint(6) unsigned NOT NULL default '0',
-> `dateformat` tinyint(1) NOT NULL default '0',
-> `timeformat` tinyint(1) NOT NULL default '0',
-> `pmsound` tinyint(1) NOT NULL default '0',
-> `showemail` tinyint(1) NOT NULL default '0',
-> `newsletter` tinyint(1) NOT NULL default '0',
-> `invisible` tinyint(1) NOT NULL default '0',
-> `timeoffset` char(4) NOT NULL default '',
-> `newpm` tinyint(1) NOT NULL default '0',
-> `accessmasks` tinyint(1) NOT NULL default '0',
-> `editormode` tinyint(1) unsigned NOT NULL default '2',
-> `customshow` tinyint(1) unsigned NOT NULL default '26',
-> `xspacestatus` tinyint(1) NOT NULL default '1',
-> PRIMARY KEY (`uid`),
-> UNIQUE KEY `username` (`username`),
-> KEY `email` (`email`),
-> KEY `groupid` (`groupid`)
-> ) ENGINE=MyISAM AUTO_INCREMENT=1828024 DEFAULT CHARSET=gbk;
Query OK, 0 rows affected (0.08 sec)mysql>
mysql> --
mysql> -- Dumping data for table `cdb_members`
mysql> --
mysql>
Query OK, 1 row affected (0.00 sec)Query OK, 1 row affected, 1 warning (0.00 sec)Query OK, 1 row affected (0.00 sec)Query OK, 1 row affected (0.00 sec)Query OK, 1 row affected, 1 warning (0.00 sec)Query OK, 1 row affected, 1 warning (0.00 sec)Query OK, 1 row affected (0.00 sec)Query OK, 1 row affected (0.00 sec)Query OK, 1 row affected (0.00 sec)Query OK, 1 row affected (0.00 sec)ERROR 1062 (23000): Duplicate entry 'é??é??' for key 2
Query OK, 1 row affected, 1 warning (0.00 sec)Query OK, 1 row affected, 1 warning (0.00 sec)Query OK, 1 row affected, 1 warning (0.00 sec)Query OK, 1 row affected (0.00 sec)Query OK, 1 row affected, 1 warning (0.00 sec)Query OK, 1 row affected (0.00 sec)Query OK, 1 row affected (0.00 sec)
1869 ??‘??– 788e73e456ca35e2291c025f76ff3d71 0 0 10 0 222.240.143.34 1175003719 222.240.143.34 1191748853 1190871241 1183975100 2 0 2 0 14 0 0 0 0 0 0 0 0 0000-00-00 0 0 0 0 0 0 1 1 1 0 9999 1 0 2 26 1
1859 ?…¨???è?¤ 25f9e794323b453885f5181f1b624d0b 0 0 10 0 222.240.143.34 1175002621 58.44.34.147 1187565756 1175002621 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0000-00-00 0 0 0 0 0 0 1 1 1 0 9999 1 0 2 26 0
1849 xixi 51737bfcac9e601ee053493d17d07f44
MySQL 中文显示乱码set names 'gbk';
还是不行,知道为什么csdn结贴率是0%的人那么多么?解决问题都解决不清楚,要么叫人家google要么让人家看文章,难道不知道实际情况不一样么。郁闷。