Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A MySQL script that will generate a list of statements to drop all DBs on a server.
-- Run this script
SELECT CONCAT('DROP DATABASE `', schema_name, '`;') AS stmt
FROM information_schema.schemata
WHERE schema_name NOT IN ('information_schema', 'performance_schema', 'mysql')
ORDER BY SCHEMA_NAME;
-- Copy the output into your clipboard
SET FOREIGN_KEY_CHECKS = 0;
-- Paste from the clipboard and run the "drop" set
SET FOREIGN_KEY_CHECKS = 1;
-- USE WITH CAUTION
-- CREDIT: http://stackoverflow.com/a/18279731/632985
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.