Revision: 35577
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 10, 2010 14:15 by terrencewood
Initial Code
#!/usr/bin/perl $username = 'root'; $password = 'root'; $pattern = 'tmpdb'; $filename = '/tmp/tmpdb.txt'; $mysql = '/opt/local/bin/mysql5'; $show_command = "$mysql -u$username -p$password -e 'show databases;' > $filename"; system($show_command); open(INPUT, $filename); $delete_command = "$mysql -u$username -p$password -e 'drop database "; @databases = <INPUT>; foreach (@databases){ if (/$pattern/) { print($_); system($delete_command . $_ . "'"); } } print("Done\n"); system("rm $filename");
Initial URL
Initial Description
Initial Title
Drop mysql databases matching a pattern
Initial Tags
Initial Language
Perl