Sunday, August 5, 2012

MySQL drop all tables that follow a pattern

Playing around with drupal I had to drop all tables that were created by a module. To do so I used the following chain of commands :
mysql -u your_user -D your_database_name -e "show tables" -s | 
  egrep "^Whatever_" | 
  xargs -I "@@" echo mysql -u your_user -D your_database_name -e "DROP TABLE @@"

This will print out all the shell commands to drop the tables beginning with "Whatever_" (note the ^ regex notation). If you want it to actually execute those commands, remove the word "echo".

“Request for the permission of type 'System.Web.AspNetHostingPermission’” fix

If you try to transfer an old DNN installation to a brand new Windows Server 2008 R2 you will probably run in the following run time error:
" System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."