mysqldump

mysqldump

编码文章call10242025-06-10 12:13:194A+A-
mysqldump \
  # 连接和基础配置
  --login-path=cyzt \
  --default-character-set=utf8mb4 \
  
  # 事务和性能控制
  --single-transaction \
  --quick \
  
  # 输出内容控制
  --skip-add-locks \
  --no-create-info \
  --where="id < 'abd'" \
  
  # 操作对象
  database table > partial_backup.sql
[备份过程]
├─ 开始连接 (--login-path)
├─ 设置字符集 (--default-character-set)
├─ 开启事务 (--single-transaction)
│  ├─ 短暂全局读锁(<1秒)
│  └─ 创建一致性快照
├─ 数据检索 (--quick)
│  ├─ 不使用内存缓存
│  └─ 逐行流式传输
├─ 跳过锁机制 (--skip-lock-tables)
├─ 条件过滤 (--where)
└─ 写入文件 (无CREATE语句因--no-create-info)
mysql -u Username \          # 连接参数组
      -p$1 \                 # 密码(从脚本参数$1获取)
      -h 198.222.333.444 \   # 主机IP
      -P 8886 \              # 端口
      --single-transaction \ # 事务控制组
      --quick \              # 性能优化组
      --skip-add-locks \     # 锁控制组
      --no-create-info \     # 输出内容控制组
      --set-gtid-purged=off \
      --where="txn_dt='20250606' and txn_type=1" \ # 数据筛选
      dbName \               # 操作对象组
      tbname > backup.sql    # 输出重定向
点击这里复制本文地址 以上内容由文彬编程网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

文彬编程网 © All Rights Reserved.  蜀ICP备2024111239号-4