Mysqldump 匯出表結構異常

Yann發表於2019-08-28

這兩天備份資料發現匯出來的表PK的AUTO_INCREMENT屬性丟失:

--skip-opt -q -R --set-gtid-purged=OFF --extended-insert --add-drop-database --add-drop-table --single-transaction

發現如下:

  • –skip-opt 選項,相當於

    --add-drop-table, --add-locks,
    --create-options, --quick, --extended-insert,
    --lock-tables, --set-charset, and --disable-keys
  • --created-options :

    -a, --create-options  Include all MySQL specific create options.
  • 如果把它disable的話,備份出來的表結構,會少了:

    AUTO_INCREMENT   --PK欄位的AUTO_INCREMENT屬性以及資料表的AUTO_INCREMENT屬性都會丟掉
    ENGINE=InnoDB DEFAULT CHARSET=utf8  --資料表的引擎、字符集屬性

加上 -a 後正常

相關文章