2014-07-13 15:45:41
来 源
中存储网
mysqlcmd
经过我自己的实践:latin1->utf8 (mysql5.0.1)注意到执行命令的时出现了一个警告,但可以产生文件,也许没有写对utf8这个名字;生成的book1.sql文件内容如下:-- MySQL dump 10.11---- Host: localho

经过我自己的实践:latin1->utf8 (mysql5.0.1)

mysql 数据字符转换latin1-utf8 (mysql5.0.1)(原创) - wv19831124 -

 注意到执行命令的时出现了一个警告,但可以产生文件,也许没有写对utf8这个名字;

生成的book1.sql文件内容如下:

-- MySQL dump 10.11
--
-- Host: localhost    Database: book
-- ------------------------------------------------------
-- Server version 5.0.45-community-nt

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES latin1 */;
/*!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 `book`
--

DROP TABLE IF EXISTS `book`;
CREATE TABLE `book` (
  `id` int(6) NOT NULL auto_increment,
  `title` varchar(100) NOT NULL default '',
  `author` varchar(100) NOT NULL default '',
  `publisher` varchar(50) NOT NULL default '',
  `publish_year` year(4) NOT NULL default '0000',
  `total` int(3) NOT NULL default '0',
  `leave_number` int(3) NOT NULL default '0',
  `other` text,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `book`
--

LOCK TABLES `book` WRITE;
/*!40000 ALTER TABLE `book` DISABLE KEYS */;
INSERT INTO `book` VALUES (1,'PHP教程','张一','电力出版社',2000,5,3,''),(3,'mysql指南','王啦啦','人民邮电出版社',2001,4,3,''),(4,'php数据库实例','郭祥','机械工业出版社',2002,5,5,''),(2,'UML与软件建模','王伟','清华大学出版社',2007,4,3,NULL);
/*!40000 ALTER TABLE `book` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `lend`
--

DROP TABLE IF EXISTS `lend`;
CREATE TABLE `lend` (
  `id` int(6) NOT NULL auto_increment,
  `book_id` int(6) NOT NULL default '0',
  `book_title` varchar(100) NOT NULL default '',
  `lend_time` date NOT NULL default '0000-00-00',
  `renew_time` date default NULL,
  `user_id` int(3) NOT NULL default '0',
  PRIMARY KEY  (`id`,`user_id`)
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `lend`
--

LOCK TABLES `lend` WRITE;
/*!40000 ALTER TABLE `lend` DISABLE KEYS */;
INSERT INTO `lend` VALUES (7,2,'','2007-10-29',NULL,2),(6,1,'','2007-10-29',NULL,1),(8,3,'','2007-10-29',NULL,3),(9,1,'','2007-10-29',NULL,2);
/*!40000 ALTER TABLE `lend` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `lend_log`
--

DROP TABLE IF EXISTS `lend_log`;
CREATE TABLE `lend_log` (
  `id` int(8) NOT NULL auto_increment,
  `book_id` int(6) NOT NULL default '0',
  `user_id` int(3) NOT NULL default '0',
  `lend_time` date NOT NULL default '0000-00-00',
  `return_time` date default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `lend_log`
--

LOCK TABLES `lend_log` WRITE;
/*!40000 ALTER TABLE `lend_log` DISABLE KEYS */;
INSERT INTO `lend_log` VALUES (8,3,3,'2007-10-29',NULL),(7,2,2,'2007-10-29',NULL),(6,1,1,'2007-10-29',NULL),(9,1,2,'2007-10-29',NULL);
/*!40000 ALTER TABLE `lend_log` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `user`
--

DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` int(3) NOT NULL auto_increment,
  `name` varchar(20) NOT NULL default '',
  `password` varchar(50) NOT NULL default '',
  `address` varchar(50) default NULL,
  `tel` varchar(20) default NULL,
  `email` varchar(50) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `user`
--

LOCK TABLES `user` WRITE;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` VALUES (1,'王伟','202cb962ac59075b964b07152d234b70','','','l@t.m'),(2,'王伟','202cb962ac59075b964b07152d234b70','8#527','33759797','wv1124@56.com'),(3,'王伟','202cb962ac59075b964b07152d234b70','咸阳师范学院8#527','33759797','wv1124@56.com');
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2008-09-18 14:20:17
注意:利用记事本打开将其另存为UTF-8格式,并替换所有的latin1为utf-8;

mysql 数据字符转换latin1-utf8 (mysql5.0.1)(原创) - wv19831124 -

再导入就行:

user book;

source book1.sql;

注意在命令行可能还会看到乱码,也许命令行不支持utf8;但使用工具查看正常;

mysql 数据字符转换latin1-utf8 (mysql5.0.1)(原创) - wv19831124 -

(或使用sqlyog工具导入)

mysql 数据字符转换latin1-utf8 (mysql5.0.1)(原创) - wv19831124 -

mysql 数据字符转换latin1-utf8 (mysql5.0.1)(原创) - wv19831124 -

mysql 数据字符转换latin1-utf8 (mysql5.0.1)(原创) - wv19831124 -

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。