DB版本:5.5.14
OS:CentOS 6.3
在测试环境中,在一台服务器上创建多个实例,在每个实例中一个一个删库比较麻烦,因此用下面脚本,可以直接删除所有库,除了系统库以外:
#!/bin/bash
mysql=/export/servers/mysql/bin/mysql
for i in {3361..3362}
do
for j in $($mysql -uroot -p123456 -S /export/data/mysql/tmp/mysql$i.sock -e "show databases" |egrep -v "information_schema|mysql|test|performance_schema|Database")
do
$mysql -uroot -p123456 -S /export/data/mysql/tmp/mysql$i.sock -e "drop database \`$j\`"
done
done