Quantcast
Channel: S.G. Vulcan » Bash scripting
Viewing all articles
Browse latest Browse all 12

Drop all databases from mysql

$
0
0

Sometimes I need to clean a mysql server so I can re-import it clean from the backups. A DROP ALL DATABASES; would have been nice, but the following does the trick. It will drop all databases except for mysql, test and information_schema

1
mysql -uroot -pPASS  -e "show databases" | grep -v Database | grep -v mysql| grep -v information_schema| grep -v test | gawk '{print "drop database " $1 ";"}' | mysql -uroot -pPASS

Warning:

It does what it says on the tin. It will DROP all your databases, no warnings, no confirmations!

 


Viewing all articles
Browse latest Browse all 12

Trending Articles