Funny, last week I made this blogpost. Today, I had to do the same, but for a MySQL 5.x database.
As I didn't wanted to start a MySQL client, I wrote a small bash command to perform the operation for me:
<a href="mailto:jochen@baileys">jochen@baileys</a> $ mysqldump -u ##USERNAME## -p##PASSWORD## --add-drop-table --no-data ##DATABASE## | grep ^DROP | mysql -u ##USERNAME## -p##PASSWORD## ##DATABASE##
What does this command do?
- dump your database to the STDOUTPUT, with ADD-DROP lines, but don't export data, only DDL
- grep all lines which start with the "DROP" statement
- pump these lines to your mysql client (which I start on command line)
Add new comment