mysql

  • Show Grants:

      mysql --skip-column-names -e "select distinct concat('show grants for''',user,'''@''',host,''';') as query from mysql.user" | \
      mysql --skip-column-names | \
      perl -ne 'next if m/(?:replica|root)/; s/$/;/; print; END {print "flush privileges;\n" }'
    

    or use maatkit

  • Show Users:

      select user,host from mysql.user;