removing conditional comments from sql backup

Posted March 10, 2020 1.4k views
DigitalOcean Managed MySQL Database


I’m having trouble with importing my production cluster to staging on digital ocean managed database

I use mysqldump with –routines –triggers –events –all-databases &set-gtid-purged=OFF parameters

every time I try to import the SQL file to my staging cluster, I’m getting the message saying I need at least one superuser privileges after looking inside the backup file I can see that at the beginning of the file there are a couple of conditional comments (’/* 50606’)

If I comment that out, the problem resolves, however, the file is way too huge to edit if I try to use vim or some other text editor it just crashes and returns me to the shell

Is there any flag or way to remove these comments? I know what they do, but in my case, it’s harmless to remove them at this moment the only thing that works for me is transferring the file to my pc and editing it with some third party text editor, but it’s just time-consuming and not-efficient

So far, I tried using –skip-comments, and that didn’t help.

I’m trying to remove this line right here.


P.S I’m exporting this file from another managed database, so I have no idea how did we manage to import it with that line in the first place

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there @omercohen,

Have you tried using the --compact flag?

As a workaround, what you could also try is when running the MySQL import to specify the -f flag so that it would force the import even if there is an error.


  • EDIT: I thought the process ended right after the error popped up, turns up I was wrong and I can see that the data is being migrated but I think it works!



    Thanks for the answer, unfortunately, both of the methods you wrote doesn’t work

    using the compact flag during export DOES remove the conditional comments however when I try to import, this returns a couple of table errors which I don’t want to deep dive into

    using the -f flag when importing returns the same error:

    ERROR 1227 (42000) at line 9: Access denied; you need (at least one of) the SUPER or SYSTEMVARIABLESADMIN privilege(s) for this operation

    line 9 is where the comment is