I have been trying to get PostgreSQL and Rails setup for about a week now, but cannot get past a database problem. I have all of the information configured correctly in the config/database.yml file, but cannot connect to the database with Rails. I found a link online saying that if the database field is provided in the database.yml file an IP connection will be made and if it is left blank sockets will be used. However I have not been able to connect either way. When I run: psql rails postgres I get: psql: FATAL: IDENT authentication failed for user "postgres" When I run: psql -h localhost rails postgres I get: psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "postgres", database "logs", SSL off This should be a setting in my pg_hba.con or pg_ident.conf files. However I''ve got everything wide open and tried every combination I can think of or find online. I''ve also asked on the psql-novice list, but haven''t had much success. Which gets me to the request....would anyone be willing to send me a sanatized version of their pg_*.conf files that works with a local install of Rails? Thanks for any help, Wayne
Lawrence Oluyede
2005-May-08 14:56 UTC
Re: A request of developers using PostgreSQL and Rails.
> Which gets me to the request....would anyone be willing to send me a > sanatized version of their pg_*.conf files that works with a local > install of Rails?This should be a working version of pg_hba.conf http://rafb.net/paste/results/lLCnY362.html -- Lawrence http://www.oluyede.org/blog
Michael Schuerig
2005-May-08 15:23 UTC
Re: A request of developers using PostgreSQL and Rails.
On Sunday 08 May 2005 16:50, Wayne Pierce wrote:> I have been trying to get PostgreSQL and Rails setup for about a week > now, but cannot get past a database problem. I have all of the > information configured correctly in the config/database.yml file, but > cannot connect to the database with Rails. > > I found a link online saying that if the database field is provided > in the database.yml file an IP connection will be made and if it is > left blank sockets will be used. However I have not been able to > connect either way. > > When I run: > psql rails postgres > I get: > psql: FATAL: IDENT authentication failed for user "postgres"Assuming you''re using a Unix/Linux variant. Do you have an ident daemon installed (either as a daemon proper or run through inetd)? Without that ident authentication can''t work. It''s not necessary, though, when you''re running your Rails app and PostgreSQL on the same machine. In that case, sameuser authentication is the easier choice.> Which gets me to the request....would anyone be willing to send me a > sanatized version of their pg_*.conf files that works with a local > install of Rails?My pg_ident.conf is all comments. Here''s the only non-comment part of my pg_hba.conf, which is untouched from its original state (Debian package). # TYPE DATABASE USER CIDR-ADDRESS METHOD # "local" is for Unix domain socket connections only local all all ident sameuser # IPv4 local connections: host all all 127.0.0.1/32 ident sameuser # IPv6 local connections: host all all ::1/128 ident sameuser Another thing: I''d rather not access the database as user postgres with all the associated power. I recommend the following setup. * Create a database user account corresponding to your OS account, both must have the same name. * For each Rails app, create a separate database user, say railsapp, and create the app''s database with that user as owner. * Create a (database) group with the same name, i.e. railsapp, and add your (database) user account to that group. * Grant the necessary privileges per table to group railsapp. Can be tedious, better don''t do this manually. Please note that I''m very far from being a PgSql master, so take all this with a huge grain of salt. Consider creating an OS user account ("railsapp") for running the app in production mode. Michael -- Michael Schuerig There is no matrix, mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org only reality. http://www.schuerig.de/michael/ --Lawrence Fishburn