11

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.

1
  • Could you provide additional information? What is the version of MySQL Server? What method you use for restoring - is it via mysql command line client, through external program like DBVisualizer, or some other way? And how did you originally crate the triggers with the "#" comment lines, what tool or client was used?
    – dabest1
    Commented Oct 14, 2011 at 1:18

1 Answer 1

21

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 !!!

3
  • deleting my response; yours seems more legit
    – atxdba
    Commented Oct 14, 2011 at 2:59
  • Deleting my answer as well. Looks like --comments option is introduced starting from MySQL 5.0.52 and MySQL 5.1.23.
    – dabest1
    Commented Oct 14, 2011 at 4:00
  • It is creating comments in dump file, but when restoring DB using mysql source command, comments are getting removed. Commented Jan 11, 2021 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.