[root@demo scripts]# mysql -uroot -poldboy123 -S /data/3306/mysql.sock -e"show databases"mysql
+--------------------+sql
| Database |vim
+--------------------+ide
| information_schema |spa
| binlog |orm
| liu |ip
| mysql |it
| oldboy |io
| performance_schema |form
| qq |
| riziwenjian |
| shaopeng |
| shujuku |
| test |
| uu |
| wodeshujk |
| xindata |
| zonglizhu |
+--------------------+
[root@demo scripts]# sh del.sh
[root@demo scripts]# mysql -uroot -poldboy123 -S /data/3306/mysql.sock -e"show databases"
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
[root@demo scripts]# vim del.sh
#!/bin/sh
for dbname in `mysql -uroot -poldboy123 -S /data/3306/mysql.sock -e"show databases"|sed '1,2d'|egrep -v "mysql|schema"`
do
mysql -uroot -poldboy123 -S /data/3306/mysql.sock -e "drop database $dbname;"
done