Created
July 5, 2011 19:09
-
-
Save flores/1065603 to your computer and use it in GitHub Desktop.
quick and dirty mysql grant checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
#die "usage: $0 <mysql_server_hostname>" unless (@ARGV > 0); | |
#my $server=@ARGV; | |
#chomp $server; | |
#my @users=`ssh $server "echo \"select user,host from mysql.user;\" | /usr/bin/mysql"`; | |
my @users=`echo "select user,host from mysql.user" | /usr/bin/mysql`; | |
chomp @users; | |
my ($line, $user, $ip); | |
foreach $line (@users) | |
{ | |
$line=~/^(\w+)\s+?(.+)/; | |
$user="$1"; | |
$ip="$2"; | |
#print "user $user ip $ip \n"; | |
system "echo \"show grants for \'$user\'@\'$ip\';\" | /usr/bin/mysql"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment