Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

How can I write a script to automate MySQL database grants in a very easy way?

I have a config file that contains the grant changes I want to make. I want the script to read the config file, and make any necessary changes to the access rights as specified in the config file. Essentially, I want the target rights to match the rights in the config file.

share|improve this question
2  
I'm sorry, but what is your question? You want to write a script (so you need to choose a language: perl,python,etc). Then you code the logic you want around the SHOW GRANTS, GRANT, and REVOKE sql commands through the mysql command line. –  Derek Downey Jul 26 '12 at 13:43
add comment

1 Answer

How about a script that runs SHOW GRANTS, parses the results, and compares it to what it parsed from your config file. Given that info, you can GRANT or REVOKE until the two lists match.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.