Thread: psql: FATAL: role "xyz" is not permitted to log in
I just can't connect to a database, though I can to others as other users...
postgres=# CREATE ROLE xyz WITH password 'abc' ;
CREATE ROLE
postgres=# CREATE DATABASE LabNews_dev WITH OWNER=xyz ENCODING='UTF8' ;
CREATE DATABASE
postgres=# grant create, connect on database LabNews_dev to xyz with grant option;
GRANT
--------------------------------
In pg_hba.conf:
local LabNews_dev labnews trust
host LabNews_dev labnews ###.###.###.###/32 trust # crushinator (Taylor)
-------------------------------
In postgresql.conf:
listen_addresses = '*'
#ssl = true # (change requires restart)
#password_encryption = on
------------------------------
I've reloaded (& restarted) the DB
=======================================
WHAT DOESN'T WORK:
postgres@flexo:~/8.2/main$ psql -U xyz LabNews_dev
psql: FATAL: database "LabNews_dev" does not exist
okay...
postgres@flexo:~/8.2/main$ psql -U xyz labnews_dev
psql: FATAL: no pg_hba.conf entry for host "[local]", user "labnews", database "labnews_dev", SSL off
AND REMOTELY:
smithrn@smithrn-ltb1:~$ psql -h thathost -U xyz labnews_dev
Password for user labnews:
psql: FATAL: password authentication failed for user "labnews"
And I have ALTER ROLE'd to assure I set the password right.
=========================================
HOWEVER:
postgres@flexo:~/8.2/main$ psql -U otherdbuser otherdb
Welcome to psql 8.2.6, 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
airburst=#
and
smithrn@smithrn-ltb1:~$ psql -h flexo -U otherdbuser otherdb
Welcome to psql 8.2.7 (server 8.2.6), 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
airburst=# \q
What am I missing???
Thanks!
Ralph
=====================
Ralph Smith <smithrn@washington.edu> writes: > I just can't connect to a database, though I can to others as other > users... You're confused about the rules for case sensitivity. > postgres=# CREATE DATABASE LabNews_dev WITH OWNER=xyz ENCODING='UTF8' ; > CREATE DATABASE This got folded to lower case, since you didn't double-quote the name. However, most places where you use a database name outside the context of SQL commands, no such folding occurs --- in particular not on psql's command line, and IIRC not in pg_hba.conf either. regards, tom lane
---------------------------------------------------------------- On Apr 4, 2008, at 2:11 PM, Tom Lane wrote: --------------------------------------------------------------- > Ralph Smith <smithrn@washington.edu> writes: >> I just can't connect to a database, though I can to others as other >> users... > > You're confused about the rules for case sensitivity. > >> postgres=# CREATE DATABASE LabNews_dev WITH OWNER=xyz >> ENCODING='UTF8' ; >> CREATE DATABASE > > This got folded to lower case, since you didn't double-quote the > name. However, most places where you use a database name outside > the context of SQL commands, no such folding occurs --- in particular > not on psql's command line, and IIRC not in pg_hba.conf either. > > regards, tom lane ------------------------------------------------------------ However I'm now trying to access it using all lower case. Are you saying that IT'S confused and I should go all lower or use quotes (") not (')? Thanks again, Ralph Smith
Ralph Smith <smithrn@washington.edu> writes: > However I'm now trying to access it using all lower case. > Are you saying that IT'S confused and I should go all lower or use > quotes (") not (')? Well, you can do it either way. If you want the database to be really truly named "LabNews_dev" (mixed case) then you need to create it using the quotes, and then you'll have to use quotes *every* time you name it in SQL commands, and you'll have to be careful to use the mixed-case spelling in other contexts such as pg_hba.conf and psql command arguments. If you are okay with it really being named "labnews_dev" then you won't need quotes in your SQL commands, but you'll have to spell it in all lower case in pg_hba.conf and psql command arguments. regards, tom lane
Egg in the face time. I knew it was going to be one of those... CREATE ROLE --DOES NOT EQUAL-- CREATE USER Whereas the latter implies LOGIN priv, the former does not. I'd read about LOGIN auto-implied some time ago, but I'd not noticed that is not so w/ a created ROLE. Maybe you can smell the sulfur from where you are? Ralph Smith ===================== On Apr 4, 2008, at 2:57 PM, Tom Lane wrote: > Ralph Smith <smithrn@washington.edu> writes: >> However I'm now trying to access it using all lower case. >> Are you saying that IT'S confused and I should go all lower or use >> quotes (") not (')? > > Well, you can do it either way. > > If you want the database to be really truly named "LabNews_dev" > (mixed case) then you need to create it using the quotes, and then > you'll have to use quotes *every* time you name it in SQL commands, > and you'll have to be careful to use the mixed-case spelling in > other contexts such as pg_hba.conf and psql command arguments. > > If you are okay with it really being named "labnews_dev" then you > won't need quotes in your SQL commands, but you'll have to spell > it in all lower case in pg_hba.conf and psql command arguments. > > regards, tom lane