单机模式
# mysql -uroot -p -Ns -e "select concat(' drop database if exists ',SCHEMA_NAME,' ;') from information_schema.SCHEMATA where SCHEMA_NAME not in ('information_schema','mysql','sys','performance_schema')"
# mysql -uroot -p -Ns -e "select concat('drop user ',user,' ;') from mysql.user where user not in ('root','mysql.sys','mysql.session')"
# mysql -u root -p
在数据库上执行上述拼接而成的输出sql,完成清理!
主主模式
# mysql -uroot -p -Ns -e "select concat(' drop database if exists ',SCHEMA_NAME,' ;') from information_schema.SCHEMATA where SCHEMA_NAME not in ('information_schema','mysql','sys','performance_schema')"
# mysql -uroot -p -Ns -e "select concat('drop user ',user,' ;') from mysql.user where user not in ('root','mysql.sys','mysql.session','repl')"
# mysql -u root -p
在数据库上执行上述拼接而成的输出sql,,少删除一个 repl 用户,完成清理!