PostGreSQL - Accessing It

Started by Michaelover 22 years ago17 messagesgeneral
Jump to latest
#1Michael
michael@transmissionsllc.com

I installed RedHat 9.0 and found that PostGreSql was installed with the
OS. I started the service, tried to create a database.

I cannot access/create a database from root or any of the other accounts
I have setup for RH9. I noticed that there is a user setup for postgres
(I guess this part of the postgres install) but can't login as that
user. I can't even read or change the password. How do I get at
PostGreSql?

Secondarily - does anyone know if JDBC drivers are part of the RH9
PostGreSql install?

Thanks in advance.

Michael

#2Joshua D. Drake
jd@commandprompt.com
In reply to: Michael (#1)
Re: PostGreSQL - Accessing It

Michael wrote:

I cannot access/create a database from root or any of the other
accounts I have setup for RH9. I noticed that there is a user setup
for postgres (I guess this part of the postgres install) but can�t
login as that user. I can�t even read or change the password. How do I
get at PostGreSql?

You need to be the user postgres. Try psql -U postgres template1 . You
may also have to initdb the database.

Secondarily � does anyone know if JDBC drivers are part of the RH9
PostGreSql install?

No. Try jdbc.postgresql.org

Or you can get an all in one package from www.commandprompt.com

Sincerely,

Joshua Drake

Show quoted text

Thanks in advance.

Michael

#3Mel Roman
mel@melroman.net
In reply to: Michael (#1)
Re: PostGreSQL - Accessing It

In article <3F397B8E.8080307@commandprompt.com>, "Joshua D. Drake" wrote:

Michael wrote:

I cannot access/create a database from root or any of the other
accounts I have setup for RH9. I noticed that there is a user setup
for postgres (I guess this part of the postgres install) but can�t
login as that user. I can�t even read or change the password. How do I
get at PostGreSql?

You need to be the user postgres. Try psql -U postgres template1 . You
may also have to initdb the database.

I have the same problem as Michael. I've installed postgresql and am
running the service, but I can't log in as postgres. I just tried the
command line "psql -U postgres template1", but I get the message
"authentication failed for user 'postgres'". The administrator's manual
confirms that I first need to connect as this predefined user, but
doesn't say what that user's password is.

How can I find out the password for user postgres so that I can finally
begin working with this database?

TIA,

--

Mel Roman
mel@melroman.net

#4Thomas Beutin
tyrone@laokoon.IN-Berlin.DE
In reply to: Mel Roman (#3)
Re: PostGreSQL - Accessing It

On Wed, Aug 13, 2003 at 01:34:00AM +0000, Mel Roman wrote:

I have the same problem as Michael. I've installed postgresql and am
running the service, but I can't log in as postgres. I just tried the
command line "psql -U postgres template1", but I get the message
"authentication failed for user 'postgres'". The administrator's manual
confirms that I first need to connect as this predefined user, but
doesn't say what that user's password is.

Did You tried "su - postgres" as root? This should bring You into a
shell of the postgres user.

HTH,
-tb
--
Thomas Beutin tb@laokoon.IN-Berlin.DE
Beam me up, Scotty. There is no intelligent live down in Redmond.

#5Joshua D. Drake
jd@commandprompt.com
In reply to: Thomas Beutin (#4)
Re: PostGreSQL - Accessing It

Hello,

Is this the default install for RedHat? What is the contents of your
pg_hba.conf file?

Thomas Beutin wrote:

Show quoted text

On Wed, Aug 13, 2003 at 01:34:00AM +0000, Mel Roman wrote:

I have the same problem as Michael. I've installed postgresql and am
running the service, but I can't log in as postgres. I just tried the
command line "psql -U postgres template1", but I get the message
"authentication failed for user 'postgres'". The administrator's manual
confirms that I first need to connect as this predefined user, but
doesn't say what that user's password is.

Did You tried "su - postgres" as root? This should bring You into a
shell of the postgres user.

HTH,
-tb

#6Paul Thomas
paul@tmsl.demon.co.uk
In reply to: Michael (#1)
Re: PostGreSQL - Accessing It

On 12/08/2003 23:51 Michael wrote:

I installed RedHat 9.0 and found that PostGreSql was installed with the
OS. I started the service, tried to create a database.

I cannot access/create a database from root or any of the other accounts
I have setup for RH9. I noticed that there is a user setup for postgres
(I guess this part of the postgres install) but can't login as that
user. I can't even read or change the password. How do I get at
PostGreSql?

From root, simply su postgres.

What I usually do then is use PostgreSQL's createuser command to create a
new super-user (i.e., one which can create new databases and new users).
On my developemt box, I make this the same as my login name. On production
boxes, we create a specific dba account an use that.

Secondarily - does anyone know if JDBC drivers are part of the RH9
PostGreSql install?

Yes but its in a separate RPM (on disk 2 IRC).
HTH

-- 
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller 
Business |
| Computer Consultants         | 
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+
#7Martín Marqués
martin@bugs.unl.edu.ar
In reply to: Michael (#1)
Re: PostGreSQL - Accessing It

El Mar 12 Ago 2003 19:51, Michael escribió:

I installed RedHat 9.0 and found that PostGreSql was installed with the
OS. I started the service, tried to create a database.

I cannot access/create a database from root or any of the other accounts
I have setup for RH9. I noticed that there is a user setup for postgres
(I guess this part of the postgres install) but can't login as that
user. I can't even read or change the password. How do I get at
PostGreSql?

Login as root to change the password of the postgres user.
You can't login as other users surelly because your pg_hba.conf has
autentification against the database users (Don't know for sure cause I don't
have a RH9 at hand now).

Secondarily - does anyone know if JDBC drivers are part of the RH9
PostGreSql install?

Yes, but it comes as a seperated package: postgresql-jdbc

--
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués | mmarques@unl.edu.ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Mel Roman (#3)
Re: PostGreSQL - Accessing It

Mel Roman <mel@melroman.net> writes:

How can I find out the password for user postgres so that I can finally
begin working with this database?

You don't need to --- and you ought to change it away from whatever it
was factory-set as, anyway. Become root and set postgres' password to
something you like.

regards, tom lane

#9Mel Roman
mel@melroman.net
In reply to: Michael (#1)
Re: PostGreSQL - Accessing It

In article <20030813043808.A15117@laokoon.bug.net>, Thomas Beutin wrote:

I have the same problem as Michael. I've installed postgresql and am
running the service, but I can't log in as postgres. I just tried the
command line "psql -U postgres template1", but I get the message
"authentication failed for user 'postgres'". The administrator's manual
confirms that I first need to connect as this predefined user, but
doesn't say what that user's password is.

Did You tried "su - postgres" as root? This should bring You into a
shell of the postgres user.

Thanks for your response. Sorry for not getting back to you guys sooner
(I was away).

I've changed the password for postgres now and am able to successfully
get into psql as postgres. I'm now having problems adding myself as a
user. After reading the admininstrator's manual I connected as postgres
and did a CREATE USER add myself as a user. When I then try to connect
as myself ("mel"), psql tells me that I'm not set up as a user. I've
copied my session below for clarity. What am I doing wrong?

[mel@Cr168131-a mel]$ su postgres
Password:
bash-2.05b$ psql test
Welcome to psql, the PostgreSQL interactive terminal.

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

test=# CREATE USER mel CREATEDB
test-# \q
bash-2.05b$ exit
exit
[mel@Cr168131-a mel]$ psql test
psql: FATAL 1: user "mel" does not exist

--

Mel Roman
mel@melroman.net

#10Mel Roman
mel@melroman.net
In reply to: Michael (#1)
Resolved: PostGreSQL - Accessing It

test=# CREATE USER mel CREATEDB
test-# \q
bash-2.05b$ exit
exit
[mel@Cr168131-a mel]$ psql test
psql: FATAL 1: user "mel" does not exist

I just figured out my problem. As you can see from my CREATE USER
command above, I simply forgot to put the semicolon at the end. Doah!
I guess it's been a little while since I've done much SQL. I've since
successfully made myself a user and life is good.

Thanks for everyone's help.

--

Mel Roman
mel@melroman.net

#11Jonathan Bartlett
johnnyb@eskimo.com
In reply to: Mel Roman (#9)
Re: PostGreSQL - Accessing It

You haven't created a user. Create User is a postgresql statement, and
must be terminated w/ a colon. I don't think your syntax is right either.
You \q'd before your statement was complete.

However, it's even eeasier to do create user from the command line (i.e.
NOT in psql mode, but still as user postgres)

createuser mel

Do this from the _shell_ prompt not the postgresql prompt.

Jon

On Thu, 14 Aug 2003, Mel Roman wrote:

Show quoted text

In article <20030813043808.A15117@laokoon.bug.net>, Thomas Beutin wrote:

I have the same problem as Michael. I've installed postgresql and am
running the service, but I can't log in as postgres. I just tried the
command line "psql -U postgres template1", but I get the message
"authentication failed for user 'postgres'". The administrator's manual
confirms that I first need to connect as this predefined user, but
doesn't say what that user's password is.

Did You tried "su - postgres" as root? This should bring You into a
shell of the postgres user.

Thanks for your response. Sorry for not getting back to you guys sooner
(I was away).

I've changed the password for postgres now and am able to successfully
get into psql as postgres. I'm now having problems adding myself as a
user. After reading the admininstrator's manual I connected as postgres
and did a CREATE USER add myself as a user. When I then try to connect
as myself ("mel"), psql tells me that I'm not set up as a user. I've
copied my session below for clarity. What am I doing wrong?

[mel@Cr168131-a mel]$ su postgres
Password:
bash-2.05b$ psql test
Welcome to psql, the PostgreSQL interactive terminal.

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

test=# CREATE USER mel CREATEDB
test-# \q
bash-2.05b$ exit
exit
[mel@Cr168131-a mel]$ psql test
psql: FATAL 1: user "mel" does not exist

--

Mel Roman
mel@melroman.net

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

#12Andrew L. Gould
algould@datawok.com
In reply to: Mel Roman (#9)
Re: PostGreSQL - Accessing It

On Thursday 14 August 2003 08:50 am, Mel Roman wrote:

In article <20030813043808.A15117@laokoon.bug.net>, Thomas Beutin wrote:

I have the same problem as Michael. I've installed postgresql and am
running the service, but I can't log in as postgres. I just tried the
command line "psql -U postgres template1", but I get the message
"authentication failed for user 'postgres'". The administrator's manual
confirms that I first need to connect as this predefined user, but
doesn't say what that user's password is.

Did You tried "su - postgres" as root? This should bring You into a
shell of the postgres user.

Thanks for your response. Sorry for not getting back to you guys sooner
(I was away).

I've changed the password for postgres now and am able to successfully
get into psql as postgres. I'm now having problems adding myself as a
user. After reading the admininstrator's manual I connected as postgres
and did a CREATE USER add myself as a user. When I then try to connect
as myself ("mel"), psql tells me that I'm not set up as a user. I've
copied my session below for clarity. What am I doing wrong?

[mel@Cr168131-a mel]$ su postgres
Password:
bash-2.05b$ psql test
Welcome to psql, the PostgreSQL interactive terminal.

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

test=# CREATE USER mel CREATEDB
test-# \q
bash-2.05b$ exit
exit
[mel@Cr168131-a mel]$ psql test
psql: FATAL 1: user "mel" does not exist

In the psql session above, was there really no semicolon or \g after CREATEDB
and before \q? If not, the CREATE USER statement was never executed.

I hope this helps.

Andrew Gould

#13Doug McNaught
doug@mcnaught.org
In reply to: Michael (#1)
Re: PostGreSQL - Accessing It

Mel Roman <mel@melroman.net> writes:

[CREATE USER isn't working]

test=# CREATE USER mel CREATEDB
test-# \q

You need a semicolon to terminate the SQL statement--you're quitting
psql before the statement is complete, so it does nothing (you can
tell the statement is incomplete by the change in the prompt if you
look closely).

-Doug

#14Karsten Hilbert
Karsten.Hilbert@gmx.net
In reply to: Mel Roman (#10)
Re: Resolved: PostGreSQL - Accessing It

test=# CREATE USER mel CREATEDB
test-# \q
bash-2.05b$ exit
exit
[mel@Cr168131-a mel]$ psql test
psql: FATAL 1: user "mel" does not exist

I just figured out my problem. As you can see from my CREATE USER
command above, I simply forgot to put the semicolon at the end. Doah!

Does this not suggest that psql should print a warning:
"still inside SQL query, really quit ? [y/n]" when in the
above situation ?

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

#15Bruce Momjian
bruce@momjian.us
In reply to: Karsten Hilbert (#14)
Re: Resolved: PostGreSQL - Accessing It

Karsten Hilbert wrote:

test=# CREATE USER mel CREATEDB
test-# \q
bash-2.05b$ exit
exit
[mel@Cr168131-a mel]$ psql test
psql: FATAL 1: user "mel" does not exist

I just figured out my problem. As you can see from my CREATE USER
command above, I simply forgot to put the semicolon at the end. Doah!

Does this not suggest that psql should print a warning:
"still inside SQL query, really quit ? [y/n]" when in the
above situation ?

That's an idea, but this is the first time someone has complained about
this. Seems we should see if more people are affected before adding a
"nag" option.

I wonder if we should have a "novice" mode for psql? Are there other
things it could control?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#16Jim Rosenberg
jr@amanue.com
In reply to: Bruce Momjian (#15)
Re: Resolved: PostGreSQL - Accessing It

--On Saturday, August 16, 2003 11:40 AM -0400 Bruce Momjian
<pgman@candle.pha.pa.us> wrote:

I wonder if we should have a "novice" mode for psql? Are there other
things it could control?

Change the prompt when output is redirected with \o.

I don't know how many times I've redirected output with \o to get a single
query in HTML, then forgotten that I did that and been puzzled why my
subsequent queries didn't show any results! There's always this
head-slap-the-forehead moment when I finally take a look at the HTML, and
see all this "other" stuff on the end ... :-)

#17Karsten Hilbert
Karsten.Hilbert@gmx.net
In reply to: Bruce Momjian (#15)
Re: Resolved: PostGreSQL - Accessing It

I wonder if we should have a "novice" mode for psql? Are there other
things it could control?

It could make the "inside some operation" prompts more verbose
and/or more in-your-face.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346