|
mysqldump 备份参数解锁 -w 导出表中的符合条件的数据
mysqldump --login-path=test test user -w "id=42237" --result-file=/data01/w.sql
导出表test 中id=42237 的记录 并且记录到/data01/w.sql 文件中
查看w.sql
[iyunv@mysql ~]# cd /data01
[iyunv@mysql data01]# more w.sql
-- MySQL dump 10.13 Distrib 5.6.22, for Linux (x86_64)
--
-- Host: localhost Database: test
-- ------------------------------------------------------
-- Server version5.6.22-log
/*!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' */;
/*!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 `user`
DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user` (
`name` varchar(10) NOT NULL,
`sex` char(1) DEFAULT NULL,
`birth` date DEFAULT NULL,
`addr` varchar(50) DEFAULT NULL,
`phone` varchar(12) DEFAULT NULL,
`age` varchar(3) DEFAULT NULL,
`id` varchar(10) NOT NULL DEFAULT '',
`id2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `user`
--
-- WHERE: id=42237
LOCK TABLES `user` WRITE;
/*!40000> INSERT INTO `user` VALUES ('hucheng','1','1992-01-01','zhejiang','18606512780','25','42237 ','nihao'); 只有一条记录符合条件
/*!40000> 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 2015-03-30 11:53:44
-d 只导出对象结构不导出数据
mysqldump --login-path=test test user -d --result-file=/data01/w.sql
导出表TEST 的结构
[iyunv@mysql data01]# more w.sql
-- MySQL dump 10.13 Distrib 5.6.22, for Linux (x86_64)
--
-- Host: localhost Database: test
-- ------------------------------------------------------
-- Server version5.6.22-log
/*!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' */;
/*!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 `user`
DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user` (
`name` varchar(10) NOT NULL,
`sex` char(1) DEFAULT NULL,
`birth` date DEFAULT NULL,
`addr` varchar(50) DEFAULT NULL,
`phone` varchar(12) DEFAULT NULL,
`age` varchar(3) DEFAULT NULL,
`id` varchar(10) NOT NULL DEFAULT '',
`id2` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) 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 */;
/*!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 2015-03-30 11:54:19
-t 只导出数据不到处结构
mysqldump --login-path=test test user -t --result-file=/data01/w.sql
只导出user 表的数据
[iyunv@mysql data01]# more w.sql
-- MySQL dump 10.13 Distrib 5.6.22, for Linux (x86_64)
--
-- Host: localhost Database: test
-- ------------------------------------------------------
-- Server version5.6.22-log
/*!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' */;
/*!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 */;
--
-- Dumping data for table `user`
--
LOCK TABLES `user` WRITE;
/*!40000> INSERT INTO `user` VALUES ('hucheng','1','1992-01-01','zhejiang','18606512780','25','1','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','10 ','nihao'),('hucheng','1','19
92-01-01','zhejiang','18606512780','25','100 ','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','1000 ','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25'
,'10000 ','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100000','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100001','nihao'),('hucheng','1','1992
-01-01','zhejiang','18606512780','25','100002','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100003','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','
100004','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100005','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100006','nihao'),('hucheng','1','1992-0
1-01','zhejiang','18606512780','25','100007','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100008','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','10
0009','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','10001 ','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100010','nihao'),('hucheng','1','1992-01-
01','zhejiang','18606512780','25','100011','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100012','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','1000
13','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100014','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100015','nihao'),('hucheng','1','1992-01-01
','zhejiang','18606512780','25','100016','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100017','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100018
','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100019','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','10002 ','nihao'),('hucheng','1','1992-01-01',
'zhejiang','18606512780','25','100020','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100021','nihao'),('hucheng','1','1992-01-01','zhejiang','18606512780','25','100022',
[iyunv@mysql data01]# more w1.sql
|
|