MySQL permissions for a Rails app

By: Johnathon Wright on: May 21, 2011

Here's how I typically setup my rails environments. NOTE: I don't include stored procedure or view permissions because Rails doesn't ever use those. Wouldn't it be great if Rails used views or stored procedures? Actually, I kinda like it the way it is. Stored Procedures are nice but the tradeoff, IE having business logic in the app and in the database, is a high price to pay. As for views, actually, that might be really nice for some reporting things. Maybe that'll be a new gem... :) but for now, stick with these.

DEVELOPMENT MACHINE

I create a dev user and a test machine. For each app, I create appdev and apptest.


CREATE USER test IDENTIFIED BY 'somepass' CREATE USER test IDENTIFIED BY 'somepass'

GRANT ALL ON app_dev.* to dev;

GRANT ALL ON app_test.* to test;

In production I typically have three environments: edge, staging, production. Each has its own database and user.

---mysql CREATE USER 'edge'@'localhost' IDENTIFIED BY 'somepass' CREATE USER 'staging'@'localhost' IDENTIFIED BY 'somepass' CREATE USER 'production'@'localhost' IDENTIFIED BY 'somepass'

/* note that, counterintuitively, you do NOT have to / / create these databases first. You can let / / the Rails app do that with rake db:create or whatever. / GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX ON app_edge. GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX ON app_staging.*

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX ON app_production.*





Comments:

off white hoodie said: I'm just commenting to make you understand of the cool discovery my friend's princess obtained studying your site. She came to understand a lot of things, including what it is like to possess a very effective teaching mindset to let the others with ease completely grasp some complex subject matter. You actually surpassed our expectations. I appreciate you for presenting these insightful, safe, revealing and also fun thoughts on the topic to Kate. off white hoodie [url=http://www.offwhitehoodie.us.com]off white hoodie[/url]

michael jordan shoes said: I'm also writing to make you understand what a superb experience my daughter obtained studying your blog. She discovered so many pieces, most notably what it's like to have a great helping nature to make many people just know various extremely tough topics. You actually exceeded visitors' expectations. Thanks for offering those practical, trustworthy, explanatory and also easy thoughts on this topic to Janet. michael jordan shoes

yeezy shoes said: I intended to post you one little bit of word so as to thank you very much once again over the superb information you have featured in this article. It is so wonderfully open-handed of you to grant without restraint precisely what a number of people could possibly have offered for an e-book to help make some bucks on their own, chiefly now that you might have tried it if you desired. These tactics also served to become easy way to be sure that other people online have a similar dreams similar to my very own to know the truth great deal more with respect to this problem. I am certain there are lots of more pleasurable times in the future for people who look into your blog post. yeezy shoes

yeezy boost 350 said: I not to mention my buddies ended up studying the good secrets and techniques located on the website while suddenly developed a horrible feeling I never thanked the blog owner for those strategies. Most of the ladies were definitely so happy to learn all of them and have in effect sincerely been making the most of them. We appreciate you genuinely well helpful as well as for considering this kind of notable subject areas most people are really needing to learn about. My personal honest apologies for not expressing appreciation to you earlier. yeezy boost 350

paul george shoes said: I precisely needed to say thanks again. I am not sure the things I might have achieved in the absence of those points shown by you about such topic. This was a real frightening condition in my circumstances, nevertheless being able to see a specialized strategy you managed that took me to jump over gladness. I'm happier for this service and as well , trust you comprehend what a powerful job you happen to be accomplishing teaching the others thru your blog post. Most likely you have never come across all of us. paul george shoes

nike off whtie said: I really wanted to develop a quick message to be able to thank you for all the magnificent tips you are sharing here. My extensive internet search has finally been compensated with pleasant know-how to write about with my visitors. I would repeat that most of us visitors actually are definitely endowed to be in a great network with very many outstanding individuals with helpful tricks. I feel quite happy to have seen your website and look forward to some more amazing minutes reading here. Thanks a lot once again for all the details. nike off whtie

stephen curry shoes said: I wanted to send you the little bit of word to be able to thank you again considering the remarkable tactics you've shared in this article. This is certainly remarkably open-handed with you to offer publicly precisely what many individuals might have sold as an electronic book to generate some profit for their own end, primarily now that you could have tried it in case you desired. These solutions in addition acted to become easy way to realize that some people have similar dream like mine to find out a little more in regard to this problem. I'm sure there are lots of more pleasurable times up front for individuals that scan your website. stephen curry shoes

adidas yeezy said: I wanted to send a simple remark to be able to express gratitude to you for the magnificent recommendations you are giving on this site. My considerable internet look up has at the end been rewarded with high-quality insight to exchange with my great friends. I 'd state that that we site visitors are extremely lucky to dwell in a great network with so many outstanding professionals with useful techniques. I feel extremely lucky to have seen your entire webpage and look forward to so many more amazing minutes reading here. Thanks a lot once again for a lot of things. adidas yeezy

yeezy 700 said: I would like to express thanks to you just for rescuing me from this crisis. After researching throughout the search engines and obtaining concepts that were not helpful, I was thinking my life was done. Being alive without the presence of solutions to the difficulties you have sorted out all through your good write-up is a serious case, and those which might have in a wrong way damaged my career if I hadn't discovered your web page. Your own personal natural talent and kindness in taking care of a lot of things was precious. I don't know what I would've done if I had not come across such a thing like this. It's possible to at this point look forward to my future. Thanks so much for this high quality and sensible help. I won't hesitate to suggest your web page to any person who needs and wants recommendations about this matter. yeezy 700
Back