首頁  >  文章  >  資料庫  >  詳解mysqldump資料導出的問題

詳解mysqldump資料導出的問題

黄舟
黄舟原創
2017-03-27 13:21:041591瀏覽

下面小編就為大家帶來一篇詳談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中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn