Skip to content

Instantly share code, notes, and snippets.

@PerpetualBeta
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PerpetualBeta/d8b2d4e788eb24a57baa to your computer and use it in GitHub Desktop.
Save PerpetualBeta/d8b2d4e788eb24a57baa to your computer and use it in GitHub Desktop.
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