PSQL create and set up a new user

时间:2017-08-04 12:41:59

标签: add psql

I was given an old database. The colleague who maintained is long gone and nobody (inculding me) has a clue how to handle it. I am able to use SQL queries to manage the data, but now I need to add a new user with reduced priviliges.

But I am not getting anywhere. The poor documentation the colleague left tells me to ssh into the server and add the new user to pg_hba.conf file. So I did that by doing that and it looks like this now:

# IPv4 local connections:
host    all             all             127.0.0.1/32          md5
host    all             test1           x.0.0.0/8             md5
host    all             test2           x.0.0.0/8             md5
host    all             hft             x.0.0.0/8             md5
# IPv6 local connections:
host    all             all             ::1/128               md5
host    all             test1           x.0.0.0/8             md5
host    all             test2           x.0.0.0/8             md5
host    all             hft             x.0.0.0/8             md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

I can login using the users test1 or test2 without problems: psql -h xxx.xxx.xxx.xxx -U user db. But when I try the same with the new added user hft to the same database, I am getting asked for a password. But I never set a password (which might be the problem?). I restarted the db with /etc/init.d/postgresql restart before trying. But doesn't change anything.

So long story short: I want to add a new user. That user should be able to access the database and use SQL queries from anywhere.

Not sure where I am wrong, as not even the local access for my new user works.

0 个答案:

没有答案