DROP all MySQL Database tables from the command line!!
DROP all MySQL tables from the command line I had a situation today where I wanted to drop all the tables in a database, but didn't have access to a UI like phpMyAdmin. The easiest thing to do would have been to drop the entire database then re-create it, but I didn't have permissions to drop an entire database. After searching around online, this is the best solution I found: mysqldump -u username -p --no-data dbname | grep ^DROP > drop.sql mysql -u username -p dbname < drop.sql rm drop.txt Simple, and only requires 2 lines (ok, a 3rd line for cleanup). What these commands do is basically generated a mysqldump file (which included DROP commands by default), then filter the output to only show the lines that have the DROP statements. The arrow (>) redirects the output to a file. The second line then imports those SQL statements into the database. Another option I have is to use information_schema database and generate an sql script li...