Created
June 4, 2020 12:25
-
-
Save OJezu/971e357365e5465a062759c16a855b4d to your computer and use it in GitHub Desktop.
Dump all users and priviledges on MySQL server
This file contains hidden or 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
#!/bin/sh | |
mysql "$@" -AN <<'SQL' | |
SELECT CONCAT('CREATE USER ', QUOTE(user), '@', QUOTE(host), ' IDENTIFIED WITH ', QUOTE(plugin), ' AS ', QUOTE(authentication_string), ';') | |
FROM mysql.user WHERE user<>'' AND host<>'' | |
ORDER BY user, host | |
; | |
SQL | |
mysql "$@" -AN <<'SQL' | mysql "$@" | sed 's/$/;/;/^Grants for /d' | |
SELECT CONCAT('SHOW GRANTS FOR ',QUOTE(user),'@',QUOTE(host),';') | |
FROM mysql.user WHERE user<>'' AND host<>'' | |
ORDER BY user, host | |
; | |
SQL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment