詳細說明mysqldump數據備份的問題
發表時間:2023-09-04 來源:明輝站整理相關軟件相關文章人氣:
[摘要]下面小編就為大家帶來一篇詳談mysqldump數據導出的問題。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧1,使用mysqldump時報錯(1064),這個是因為mysqldump版本太低與當前數據庫版本不一致導致的。mysqldump: Couldnt execu...
下面小編就為大家帶來一篇詳談mysqldump數據導出的問題。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
1,使用mysqldump時報錯(1064),這個是因為mysqldump版本太低與當前數據庫版本不一致導致的。
mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION SQL_QUOTE_SHOW_CREATE=1' at line 1 (1064)
[root@bastion-IDC ~]# mysqldump --versionmysqldump Ver 10.13 Distrib 5.1.61, for redhat-linux-gnu (x86_64)
[root@bastion-IDC ~]# mysql //或者登陸mysql,select version();也可查看版本
Server version: 5.6.25-log Source distribution。。。。。
這樣的話必須知道mysqldump的絕對路徑,在mysql的安裝目錄下有。
2,導出時指定字符集,報錯
Character set 'utf-8' is not a compiled character set and is not specifie .
--default-character-set=utf-8
這個是因為字符集錯了。是--default-character-set=utf8
3,導出時提示warning,A partial dump from a server that has GTIDs
[root@bastion-IDC ~]# mysqldump -uroot -p xqsj_db > xqsj_db20160811.sql
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,而不用原來的。
[root@bastion-IDC ~]# mysqldump -uroot --set-gtid-purged=off -p xqsj_db > xqsj_db20160811.sql #這樣就ok了!
以上就是詳解mysqldump數據導出的問題的詳細內容,更多請關注php中文網其它相關文章!
學習教程快速掌握從入門到精通的SQL知識。