Linux 下導出/備份數據庫命令
mysqldump -u用戶名 -p密碼 -d 數據庫名 > /想下載目錄/數據庫.sql
或者
mysqldump -u用戶名 -p密碼 -d 數據庫名 --set-gtid-purged=off > /想下載目錄/數據庫.sql
這裏的–set-gtid-purged=off是爲了解決一個Warning:
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.
這個warning和mysql版本有關,MySQL Distrib 5.6之後加入了全局事務標識符(global transaction identifier ,GTID)作爲在源(主)服務器上提交的每個事務中創建並關聯的惟一標識符。