4 # This script finds all tables in all databases and grants DROP permission
5 # on DBNAME.TBLNAME to corresponding DB owners.
6 # We have to do this because granting DROP on DBNAME.* also gives permission
7 # to drop DBNAME itself, which we can't allow.
9 # docelic@hcoop.net, Mon Sep 24 16:25:34 EDT 2007
12 # Exit for now; I don't know how to handle this without messing up
15 MYSQL_DBS
=`sudo -H mysqlshow | tail -n +4 | head -n -1 | cut -d' ' -f 2 | xargs`
16 #echo "Mysql Databases are: $MYSQL_DBS"
18 for DB
in $MYSQL_DBS; do
19 if (test "$DB" != "information_schema") && (test "$DB" != "mysql") && (test "$DB" != "performance_schema"); then
22 MYSQLDB_TABLES
=`sudo -H mysqlshow $DB | tail -n +5 | head -n -1 | cut -d' ' -f 2 | xargs`
23 #echo Tables in $DB are $MYSQLDB_TABLES
24 for TBL
in $MYSQLDB_TABLES; do
26 #echo "OWNER FOR $DB.$TBL is $USER"
27 sudo
-H mysql
-e "GRANT ALL PRIVILEGES ON \`$DB\`.\`$TBL\` TO $USER@'%.hcoop.net'";