语法格式: mysqldump -u root -ppassword -T 目标目录 dbname table [ option ]; ----注意,T是大写
password:表示root用户的密码,和 -p 挨着,中间没有空格;
目标目录:指导出的文本文件的路径;
dbname:表示数据库的名称;
table:表示表的名称;
option:表示附加选项,如下:
--fields-terminated-by=字符串:设置字符串为字段的分隔符,默认值是“\t”;
--fields-enclosed-by=字符:设置字符来括上字段的值;
--fields-optionally-enclosed-by=字符:设置字符括上char、varchar、text等字符型字段;
--fields-escaped-by=字符:设置转义字符;
--lines-terminated-by=字符串:设置每行的结束符;
------------------------------------------------------------------------------------------------------------------------------
mysqldump会导出2个文件一个txt一个sql文件(只有表结构):
mysqldump -u root -p123 -T C:\Users\del\Desktop see cr01 --fields-terminated-by=',' --lines-terminated-by='\r\n'
字段间的分隔符号 每行的结束符
sql文件内容:
-- MySQL dump 10.13 Distrib 5.5.15, for Win32 (x86) -- -- Host: localhost Database: see -- ------------------------------------------------------ -- Server version 5.5.15 /*!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 utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `cr01` -- DROP TABLE IF EXISTS `cr01`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cr01` ( `sx` int(50) DEFAULT NULL, `mz` varchar(50) DEFAULT NULL, `bz` varchar(50) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!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 2019-12-27 16:09:32