I wanted to do a diff on two database structures, and one answer suggested running mysqldump
on both databases and then doing diff
on the resulting scripts.
The problem is that comments will clutter the output and get in the way, and even explicit --compact
, --skip-comments
, --skip-set-charset
etc. won't help. You will still be getting comments such as below in your output.
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
If you search for mysqldump without comments, most answers will lecture you on how you actually need them, the worst kind of not being helpful.
Here's how you can force mysqldump to not include any comments:
mysqldump --compact --compatible=mysql40 --no-data -h localhost -u root -p my_database > /tmp/my_database.sql
Sources: