Обсуждение: PostgreSql-users and passwords

Поиск
Список
Период
Сортировка

PostgreSql-users and passwords

От
Elaine Araújo
Дата:
I'm bening to work with Java an PostgreSql. When i try to access a
database which is on the server using
DriverManager.getConnection("jdbc:postgresql://host:port/banco","user",
"password"); an error occurs:"User authentication failed". Where do i
configure users and passwords for my database in the Postgresql?

Can anyone help me?
Thanks,
Elaine Araujo.
ps. The application is on a cliente.


Re: [INTERFACES] PostgreSql-users and passwords

От
Peter T Mount
Дата:
[only just saw this one was about java]

On Mon, 6 Jul 1998, Elaine Arajo wrote:

>
> I'm bening to work with Java an PostgreSql. When i try to access a
> database which is on the server using
> DriverManager.getConnection("jdbc:postgresql://host:port/banco","user",
> "password"); an error occurs:"User authentication failed". Where do i
> configure users and passwords for my database in the Postgresql?

[ someone correct me as I can't confirm this yet (as I would normally do
when writing SQL) as I still yet to get postgres back up and running since
last weeks accident ]

If you log into the database as the DBA (usually postgres), you can then
create a normal user using a statement like:

mydb> CREATE USER peter WITH PASSWORD mypass ;

you can change their passwords with:

mydb> ALTER USER peter WITH PASSWORD mypass ;

Now once you have done that, you need to configure the pg_hba.conf file
(located in the PG_DATA directory). You will need to create an entry for
each database (or all for all of them) to allow remote clients access.

eg:

# This allows hosts on the 192.168.4.0 network access to all databases
host    all    192.168.4.0    255.255.255.0    crypt

# This allows a single host access to the test database
host    test    192.168.4.2    255.255.255.255    crypt

Hope that helps

--
Peter T Mount peter@retep.org.uk or petermount@earthling.net
Main Homepage: http://www.retep.org.uk
Postgresql JDBC Faq is available at http://www.retep.org.uk/postgres