2012-04-13

Readable MySQL dumps

Reading a text dump produced with mysqldump is normally hampered by the fact that the default options include --opt (for optimize), which is shorthand for a bunch of other options that make the resulting sql more concise and quicker to parse, but also very hard to read for humans as inserts are munched together into ridiculously long lines without any visual structure.

To prevent this from happening, use --skip-opt:
mysqldump -u root -p --skip-opt <dbname> > /tmp/sql.txt

For reading with less, the -S option is useful to prevent line breaking, which can be very slow.
less -S /tmp/sql.txt

No comments:

Post a Comment