Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
# 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
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.
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.
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)
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:~$
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.