if your application uses
root as your database username; you’re doing it wrong.
a good practice is you should have two users for your application. let say
i have a database called
blog_production, i will have two users in my
blog_admin. the former will be use for regular stuff,
and the latter for database administration. each db user have diffrent set of privileges.
1 2 3 4 5 6 7 8 9
now, how do you use this two users in your rails app? in
databases.yml, add a check for
DB_ADMIN env var.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
by default it uses
blog db username unless you pass
DB_ADMIN=true env var.
the reasone we have this env is because we need to pass it when we run
migration tasks e.g:
if you use capistrano for deployment, you need to set
if you have better method, hit the comments.
and that’s all there is to it. hth.