日期:2014-05-16 浏览次数:20465 次
#!/bin/bash #function export user privileges expgrants() { mysql -B -N $@ -e "SELECT CONCAT( 'SHOW GRANTS FOR ''', user, '''@''', host, ''';' ) AS query FROM mysql.user where host in('10.1.242.10', '10.1.242.35', '10.1.242.48', '10.1.20.38', '172.21.5.129','172.21.5.49', '172.21.5.50', '172.21.5.53', '172.21.5.58', '172.21.5.60', '172.21.7.201','172.21.7.219','10.1.242.235')" | \ mysql $@ | \ sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/-- \1 /;/--/{x;p;x;}' } expgrants > ./grants.sql
mysql -B -N -e "SELECT CONCAT( 'SHOW GRANTS FOR ''', user, '''@''', host, ''';' ) AS query FROM mysql.user" ./mysql -B -N -e "SELECT CONCAT( 'SHOW GRANTS FOR ''', user, '''@''', host, ''';' ) AS query FROM mysql.user " | \ mysql $@ | \ sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/-- \1 /;/--/{x;p;x;}'
./mysql -B -N -e "SELECT CONCAT( 'SHOW GRANTS FOR ''', user, '''@''', host, ''';' ) AS query FROM mysql.user" ./mysql -B -N -e "SELECT CONCAT( 'SHOW GRANTS FOR ''', user, '''@''', host, ''';' ) AS query FROM mysql.user " | \ ./mysql | \ sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/-- \1 /;/--/{x;p;x;}' 本次移服使用的: ./mysql -B -N -e "SELECT CONCAT( 'SHOW GRANTS FOR ''', user, '''@''', host, ''';' ) AS query FROM mysql.user" ./mysql -B -N -e "SELECT CONCAT( 'SHOW GRANTS FOR ''', user, '''@''', host, ''';' ) AS query FROM mysql.user " | \ ./mysql | \ sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/ /;/--/{x;p;x;}'