HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMajor

MySQL dump restore - how to retain comments

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
dumpmysqlhowretaincommentsrestore

Problem

So I have that complex MySQL dump as a backup. Unfortunately, that backup is complex and we use evil triggers.

Some of our evil triggers had a comment lines starting with the # character.

When I backup the database, the resulting dump save the # lines. The problem is when I am doing the restore. The line starting with # are replaced by empty lines.

So I am looking for a way to restore the dump WITH the lines starting with the pound.

Solution

OMG I know your problem !!!

Here is the problem: The mysql client filters out comments.

-c, --comments      Preserve comments. Send comments to the server. The
                    default is --skip-comments (discard comments), enable
                    with --comments.


Just load the mysqldump file like this:

mysql -u... -p... --comments < dumpfile.sql


Give it a Try !!!

Code Snippets

-c, --comments      Preserve comments. Send comments to the server. The
                    default is --skip-comments (discard comments), enable
                    with --comments.
mysql -u... -p... --comments < dumpfile.sql

Context

StackExchange Database Administrators Q#6804, answer score: 21

Revisions (0)

No revisions yet.