• mysqldump备份数据库


    使用mysqldump备份数据库

    mysqldump --opt ekt -uroot -ppassword -R -B --set-gtid-purged=OFF > ekt.sql

    参数说明:

    --opt

         如果加上--opt参数则生成的dump文件中稍有不同:

         . 建表语句包含drop table if exists tableName

         . insert之前包含一个锁表语句lock tables tableName write,insert之后包含unlock tables

    -R (--routines:导出存储过程以及自定义函数)


    -B (--databases:导出数据库列表,单个库时可省略)

    --set-gtid-purged=OFF

    导出时提示warning,A partial dump from a server that has GTIDs

    [root@localhost data]# mysqldump -uroot --master-data=2 -p  --single-transaction --databases test >3.sql
    Enter password: 
    Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events. 

    关于GTID是5.6以后,加入了全局事务 ID (GTID) 来强化数据库的主备一致性,故障恢复,以及容错能力。
    官方给的:A global transaction identifier (GTID) is a unique identifier created and associated with each transaction committed on the server of origin (master).
    所以可能是因为在一个数据库里面唯一,但是当导入其他的库就有可能重复。所有会有一个提醒。

    可以通过添加--set-gtid-purged=off  或者–gtid-mode=OFF这两个参数设置。
    个人认为是在导入库中重新生产GTID,而不用原来的。

    恢复数据库
    source /var/www/html/backup/ekt_new.sql

  • 相关阅读:
    Iaas、Paas、Saas对比分析
    一个不一样的Python教程
    传销的那些年
    availableProcessors is already set to [8], rejecting [8]
    脚本是个好东西
    《设计模式之禅》之桥梁模式
    博文视点之传奇程序员修炼之道观后感
    《设计模式之禅》之享元模式
    《设计模式之禅》之解释器模式
    Git修改commit提交信息
  • 原文地址:https://www.cnblogs.com/yuzhoushenqi/p/6823780.html
Copyright © 2020-2023  润新知