Delete ALL MySQL/MariaDB tables at once

Was playing with the wordpress tables and screwed up. Needed then to delete all the existing tables of the database, but didn’t want to do it one by one..

Here is a snippet that may be helpful for such tasks.

mysql -u USER -p PASSWORD -D DATABASE  -e "show tables" -s | 
egrep "^wp_" | xargs -I "@@" echo mysql -u USER -p PASSWORD -D DATABASE-e "DROP TABLE @@"

 

Change the USER, PASSWORD and DATABASE accordingly. And there is no space after the -P for the password

 

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *