Posted in
Hosting & IIS7 |
No Comment | 10,661 views | 27/12/2011 09:15
There is no quick way to drop all tables of a MySQL database. You can just drop the database instead. But if you just want to drop all tables, you can use following codes.
mysql -u root -pPASSWORD DatabaseName -e "show tables" | grep -v Tables_in | grep -v "+" | \gawk '{print "drop table " $1 ";"}' | mysql -u root -pPASSWORD DatabaseName |
mysql -u root -pPASSWORD DatabaseName -e "show tables" | grep -v Tables_in | grep -v "+" | \gawk '{print "drop table " $1 ";"}' | mysql -u root -pPASSWORD DatabaseName
I found the code from another website but it was for password-less MySQL servers. I added password authentication.