Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home1/tylerfra/public_html/includes/common.inc).

MySQL - Drop All Tables In a Database

Category: 
Tags: 

Sometimes you may not have sufficient privileges to be able to just DROP an entire database on a MySQL server. In that case, you may be able to just drop each table in the database instead. If you have one or two tables, it is easy enough to just type the 'drop table' command from a MySQL terminal, but if you have dozens and dozens of tables, this will get tedious fast. Here is a nice terminal command to drop all the tables in a database when you don't have permission to drop the database itself:

for i in `echo 'show tables;' | mysql -u my_mysql_username -h localhost -pMY_MYSQL_PASSWORD my_mysql_database_name | grep -v 'Tables_in_my_mysql_database_name'`; do echo "drop table $i;" | mysql -u my_mysql_username -h localhost -pMY_MYSQL_PASSWORD my_mysql_database_name; done

I often use this command on a MySQL server that I don't have permission to drop a database on, so I can easily clear out the database then import a mysql dump.