This seemed like a better fit here than stackoverflow, so here goes:
I've been using mysql for a while since on most of the cheap webhosts it is the provided database. However, now I've started seriously developing web apps I've been using postgresql locally for my database, with a view to using it properly on the clients installations once I'm comfortable.
The only thing I've not yet grasped (of the basics, of course) is the concept of users/groups/permissions. In mysql, I create users and I can GRANT
them permissions on the various tables I wish them to have access to.
How does this concept work in Postgres? Does it? On my local machine I've been allowing the user apache
access to my tables so that my django apps can work, via:
echo "GRANT SELECT,INSERT,UPDATE,DELETE ON TABLE $table TO $2"
echo "GRANT SELECT,INSERT,UPDATE,DELETE ON TABLE $table TO $2" | psql $1
echo "GRANT SELECT,UPDATE ON SEQUENCE ${table}_id_seq TO $2"
echo "GRANT SELECT,UPDATE ON SEQUENCE ${table}_id_seq TO $2" | psql $1
(part of a bigger script)
Is this secure? I'm pretty certain per-app users sounds like a more sensible idea, but then I don't know.
So, I guess that makes my questions:
- How do users/groups/permissions work in postgresql?
- How do they compare to mysql?
- What is considered best practise?