Paul Maunders | Web log
Economics, Business, Telecoms, Tech and Gadgets

SHOW GRANTS for all users on MySQL

October 18th, 2006 by admin

Although there isn’t yet a command (that I am aware of) to show all user GRANTS in MySQL, you can write a quick bash script to do the job if you have shell access:

#!/bin/bash
tmp=/tmp/showgrant$$
mysql --batch --skip-column-names -e "SELECT user, host FROM user" mysql > $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 in Uncategorized

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.