Skip to main content
  1. Posts/

Remove backticks from MySQL dumps

··104 words·1 min·

I found myself in a peculiar situation last week. I’d been asked to downgrade a server from MySQL 4.1 to MySQL 3.23. Believe me, I tried to advise against the request, but I didn’t succeed.

I made a MySQL 3.23 compatible dump with --compatible=mysql323, but the dump came out with backticks around the database names. This works with some 3.23 versions, but it doesn’t work with others. Apparently RHEL 3’s MySQL 3.23 is one of those versions where it simply won’t work.

This sed line came in handy to strip the backticks from the USE lines in the dump:

sed -e "s/^USE \`\(.*\)\`/USE \1/g"