设为首页 收藏本站
查看: 585|回复: 0

[经验分享] mysqldump

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-12-22 11:10:05 | 显示全部楼层 |阅读模式
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 
  
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-154704-1-1.html 上篇帖子: MYSQL 主库 下篇帖子: Windows安装解压版的MySQL
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表