Fév 192012
 

Un petit script bash pour voir les droits de tous les utilisateurs mysql.

#!/bin/bash
tmp=/tmp/showgrant$$
mysql --batch --skip-column-names -e "SELECT user, host FROM mysql.user" > $tmp
cat $tmp | while read user host
do
      echo "# $user @ $host"
      mysql --batch --skip-column-names -e"SHOW GRANTS FOR '$user'@'$host'"
done
rm $tmp
 Posted by at 16 h 06 min  Tagged with:

  One Response to “Show Grants for all mysql’s users”

  1. for account in $(mysql -Bse « select user,host from mysql.user » | sed -r ‘s/\s+/@/’ | sed -r « s/^(.*)@(.*)/\’\1\’@\’\2\’/ »);do mysql -BNe « show grants for $account »;done

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

(required)

(required)

Spam protection by WP Captcha-Free