Handy One-Liners

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

    # 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";
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Handy One-Liners

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.