LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-22-2008, 07:41 PM   #1
wyzgreg
LQ Newbie
 
Registered: Aug 2007
Posts: 27

Rep: Reputation: 15
Question postgresql issues


I have installed postgresql v8.3.0 and I am having trouble accessing databases as a regular user. I have read several howtos and docs but nothing seems to help. psql: FATAL: Ident authentication failed for user "gregdb" is what i get when i try to open the db with psql -d music -U gregdb. can you help? thanx wyzgreg
 
Old 03-22-2008, 08:52 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Hi,

And if you post your pg_hba.conf I'm sure I can help ;}

Chances are there *is* no gregdb user defined on the OS
level, which is what identd identification is all about.

Cheers,
Tink
 
Old 03-22-2008, 09:30 PM   #3
wyzgreg
LQ Newbie
 
Registered: Aug 2007
Posts: 27

Original Poster
Rep: Reputation: 15
Smile here is my pg_hba.conf

# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# Refer to the "Client Authentication" section in the
# PostgreSQL documentation for a complete description
# of this file. A short synopsis follows.
#
# This file controls: which hosts are allowed to connect, how clients
# are authenticated, which PostgreSQL user names they can use, which
# databases they can access. Records take one of these forms:
#
# local DATABASE USER METHOD [OPTION]
# host DATABASE USER CIDR-ADDRESS METHOD [OPTION]
# hostssl DATABASE USER CIDR-ADDRESS METHOD [OPTION]
# hostnossl DATABASE USER CIDR-ADDRESS METHOD [OPTION]
#
# (The uppercase items must be replaced by actual values.)
#
# The first field is the connection type: "local" is a Unix-domain socket,
# "host" is either a plain or SSL-encrypted TCP/IP socket, "hostssl" is an
# SSL-encrypted TCP/IP socket, and "hostnossl" is a plain TCP/IP socket.
#
# DATABASE can be "all", "sameuser", "samerole", a database name, or
# a comma-separated list thereof.
#
# USER can be "all", a user name, a group name prefixed with "+", or
# a comma-separated list thereof. In both the DATABASE and USER fields
# you can also write a file name prefixed with "@" to include names from
# a separate file.
#
# CIDR-ADDRESS specifies the set of hosts the record matches.
# It is made up of an IP address and a CIDR mask that is an integer
# (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that specifies
# the number of significant bits in the mask. Alternatively, you can write
# an IP address and netmask in separate columns to specify the set of hosts.
#
# METHOD can be "trust", "reject", "md5", "crypt", "password", "gss", "sspi",
# "krb5", "ident", "pam" or "ldap". Note that "password" sends passwords
# in clear text; "md5" is preferred since it sends encrypted passwords.
#
# OPTION is the ident map or the name of the PAM service, depending on METHOD.
#
# Database and user names containing spaces, commas, quotes and other special
# characters must be quoted. Quoting one of the keywords "all", "sameuser" or
# "samerole" makes the name lose its special character, and just match a
# database or username with that name.
#
# This file is read on server startup and when the postmaster receives
# a SIGHUP signal. If you edit the file on a running system, you have
# to SIGHUP the postmaster for the changes to take effect. You can use
# "pg_ctl reload" to do that.

# Put your actual configuration here
# ----------------------------------
#
# If you want to allow non-local connections, you need to add more
# "host" records. In that case you will also need to make PostgreSQL listen
# on a non-local interface via the listen_addresses configuration parameter,
# or via the -i or -h command line switches.
#




# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database
# super user can access the database using some other method.
# Noninteractive
# access to all databases is required during automatic maintenance
# (autovacuum, daily cronjob, replication, and similar tasks).
#
# Database administrative login by UNIX sockets
local all postgres ident sameuser

# TYPE DATABASE USER CIDR-ADDRESS METHOD
local all all trust
# "local" is for Unix domain socket connections only
local all all ident sameuser
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
 
Old 03-22-2008, 09:35 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
OK, my guess was correct I think (even though
it seems to ignore the all all trust - did you
add that? Did you restart the service after that?) ;}

I assume that your user-name in the OS (Debian, Ubuntu?) isn't
gregdb.

Two ways to go about that: a) create a user called that (or
rename your current user account) or b) become the postgres-user
(sudo su - postgres) and create a user that matches your own
(you're still postgres! - createuser <your os username).

And then, of course, you'll have to grant privileges on or
change ownerships of the database music to allow your user
to actually do things with it.


Cheers,
Tink

Last edited by Tinkster; 03-22-2008 at 09:36 PM.
 
Old 03-22-2008, 09:52 PM   #5
wyzgreg
LQ Newbie
 
Registered: Aug 2007
Posts: 27

Original Poster
Rep: Reputation: 15
still stuck

I've create an account (system) for gregdb. I attempted to GRANT this user permissions on the music database but, apparently, this failed. I run the commands as postgres (su - postgres) but to no avail. It seems that postgres is not recognizing the commands I issue. I have tried creating the 'music' database inside of the postgres shell but i ended up having to use 'createdb' outside of the shell to get this to work. Now there is a 'music' database, but i have to be 'postgres' to access it.
 
Old 03-22-2008, 10:10 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
OK

Assuming that mr gregdb is the one meant to be using the music
database in the first place, try this:
Code:
su - postgres
psql 

ALTER DATABASE music WITH OWNER gregdb;
Btw, which distro ARE you running?


Cheers,
Tink
 
Old 03-22-2008, 10:14 PM   #7
wyzgreg
LQ Newbie
 
Registered: Aug 2007
Posts: 27

Original Poster
Rep: Reputation: 15
no go

root@greg-desktop:~# su - postgres
postgres@greg-desktop:~$ psql
Welcome to psql 8.3.0, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

postgres=# ALTER DATABASE music WITH OWNER gregdb;
ERROR: syntax error at or near "OWNER"
LINE 1: ALTER DATABASE music WITH OWNER gregdb;
^
postgres=# ALTER DATABASE music WITH OWNER gregdb
postgres-# ;
ERROR: syntax error at or near "OWNER"
LINE 1: ALTER DATABASE music WITH OWNER gregdb
^
postgres=#
= :0
i'm using ubuntu 7.10 (gutsy gibbon)
 
Old 03-22-2008, 10:16 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Apologies ... got carried away there - skip the WITH
Code:
ALTER DATABASE music OWNER gregdb;
Cheers,
Tink
 
Old 03-22-2008, 10:21 PM   #9
wyzgreg
LQ Newbie
 
Registered: Aug 2007
Posts: 27

Original Poster
Rep: Reputation: 15
still caks up

postgres=# ALTER DATABASE music OWNER gregdb;
ERROR: syntax error at or near "gregdb"
LINE 1: ALTER DATABASE music OWNER gregdb;
^
postgres=#
 
Old 03-22-2008, 10:32 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
OK ... and now i'm awake, apologising profusely :D

What does
Code:
ALTER DATABASE music OWNER TO gregdb;
give you?


Cheers,
Tink
 
Old 03-22-2008, 10:37 PM   #11
wyzgreg
LQ Newbie
 
Registered: Aug 2007
Posts: 27

Original Poster
Rep: Reputation: 15
getting closer ??

postgres=# ALTER DATABASE music OWNER TO gregdb;
ALTER DATABASE
postgres=# /q (oops)
postgres-# \q
postgres@greg-desktop:~$ exit
logout
root@greg-desktop:~# exit
logout
greg@greg-desktop:~$ psql -d music
psql: FATAL: role "greg" does not exist
greg@greg-desktop:~$ psql -d music -U gregdb
psql: FATAL: Ident authentication failed for user "gregdb"
greg@greg-desktop:~$

Last edited by wyzgreg; 03-22-2008 at 10:46 PM.
 
Old 03-22-2008, 10:46 PM   #12
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
OK, still the same problem. Your username is greg, not gregdb. The
only way to work this (or the way to work this with the least hassle)
is to edit pg_hba.conf and add a line
Code:
local music gregdb trust
(not very safe)
or
Code:
local music gregdb md5
(much better, but you'll have to change your account
from the postgres' users psql session)
after the line
Code:
local all postgres ident sameuser
and then restart postgres
Code:
/etc/init.d/postgresql-8.3 stop && /etc/init.d/postgresql-8.3 start


Cheers,
Tink
 
Old 03-22-2008, 10:56 PM   #13
wyzgreg
LQ Newbie
 
Registered: Aug 2007
Posts: 27

Original Poster
Rep: Reputation: 15
Got it!!

Great !! Thank you so much.
I will try later with md5 (much better, right??)
/etc/init.d/postgresql-8.3 stop && /etc/init.d/postgresql-8.3 start
 
Old 03-22-2008, 11:03 PM   #14
wyzgreg
LQ Newbie
 
Registered: Aug 2007
Posts: 27

Original Poster
Rep: Reputation: 15
Got it with md5

Thanx again. can access in local user account with md5. ur a genius
 
Old 03-22-2008, 11:12 PM   #15
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Not really ... I made two stuff-ups ;}

And as for the md5 option (as postgres in psql):
Code:
alter user gregdb with encrypted password 'your_new_password_here';


Cheers,
Tink
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PostgreSql coolrock Slackware 4 10-04-2006 10:24 AM
PostgreSql sijomon_nd Fedora 1 09-27-2005 09:27 PM
postgresql -odbc & postgresql-jdbc installation kjsubbu Linux - Software 0 06-19-2003 02:50 AM
postgreSQL dsgdevil Linux - Software 3 02-20-2003 10:30 PM
PostgreSQL 7.2.2 Released due to security issues rverlander Linux - Software 0 08-24-2002 07:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration