Handy One-Liners

  • Show all MySQL Users’ GRANTS:
     Bash | 
     
     copy code |
    ?

    1
    2
    # oIFS="$IFS"; export IFS=$'\n'; for i in $(mysql --skip-column-names --batch -e "SELECT user,host FROM mysql.user"); do USER=$(echo $i|awk '{printf $1}'); HOST=$(echo $i|awk '{printf $2}'); mysql --skip-column-names --batch -e "SHOW GRANTS FOR '$USER'@'$HOST'"; done; export IFS="$oIFS";
    3
    		
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *