Exporting all MySQL user privileges
![Exporting all MySQL user privileges](https://i0.wp.com/faish.al/wp-content/uploads/2018/07/rhn0lahftwg.jpg?fit=1600%2C1200&ssl=1)
To export all MySQL user privileges run following script.
Note : Replace {host_name}, {user_name} and {password} with your values.
mysql -h {host_name} -u {user_name} -p{password} -Ne "select distinct concat( \"SHOW GRANTS FOR '\",user,\"'@'\",host,\"';\" ) from user;" mysql | mysql -h {host_name} -u {user_name} -p{password} | sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
Above script will generate all grants statements.You can then take that output and run the statements against MySQL on the new server.
Thanks for the help.!!!
nice