Detailed discussion on mysqldump data export

  • 2021-07-24 11:52:07
  • OfStack

1. Use mysqldump to report an error (1064). This is because the mysqldump version is too low and the current database version is not 1.

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 --version
mysqldump Ver 10.13 Distrib 5.1.61, for redhat-linux-gnu (x86_64)

[root @ bastion-IDC ~] # mysql//or log in to mysql, select version (); You can also view the version
Server version: 5.6.25-log Source distribution
. . . . .

In this case, you must know the absolute path of mysqldump, which is found in the installation directory of mysql.

2. Specify the character set and report an error when exporting

Character set 'utf-8' is not a compiled character set and is not specifie .
--default-character-set=utf-8

This is because the character set is wrong. Yes--default-character-set=utf8

3. Prompt warning, A partial dump from a server that has GTIDs when exporting

[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.

After GTID was 5.6, the global transaction ID (GTID) was added to strengthen the database's master-standby uniformity, failure recovery and fault tolerance.
Official: A global transaction identifier (GTID) is a unique identifier transaction with transaction committed on the server origin (master).
So it may be because there is only one in one database, but it may be duplicated when importing other libraries. All will have 1 reminder.

You can set it by adding two parameters--set-gtid-purged=off or gtid-mode=OFF.

It is quite possible to re-produce GTID in the import library instead of the original one.

[root@bastion-IDC ~]# mysqldump -uroot --set-gtid-purged=off -p xqsj_db > xqsj_db20160811.sql # This is ok!


Related articles: