Thread: Cant create new users or databases

Cant create new users or databases

From
AlphaByte
Date:
Can someone point out to me what I am doing wrong here? I
can't seem to find this in the documentation anywhere.

[root@alphabyte abyte]# createuser abyte
Shall the new user be allowed to create databases? (y/n) y
Shall the new user be allowed to create more new users? (y/n) y
NOTICE:  mdopen: couldn't open /var/lib/pgsql/pg_shadow: Permission denied
NOTICE:  RelationIdBuildRelation: smgropen(pg_shadow): Permission denied
NOTICE:  mdopen: couldn't open /var/lib/pgsql/pg_shadow: Permission denied
NOTICE:  mdopen: couldn't open /var/lib/pgsql/pg_shadow: Permission denied
psql: FATAL 1:  cannot open relation pg_shadow
createuser: creation of user "abyte" failed

Ta

Alan
--
AlphaByte: PO Box 1941, Auckland, New Zealand
Specialising in:Graphic Design, Education and Training,
Technical Documentation, Consulting.
http://www.alphabyte.co.nz

Re: Cant create new users or databases

From
John McKown
Date:
On Sat, 16 Sep 2000, AlphaByte wrote:

> Can someone point out to me what I am doing wrong here? I
> can't seem to find this in the documentation anywhere.
>
> [root@alphabyte abyte]# createuser abyte
> Shall the new user be allowed to create databases? (y/n) y
> Shall the new user be allowed to create more new users? (y/n) y
> NOTICE:  mdopen: couldn't open /var/lib/pgsql/pg_shadow: Permission denied
> NOTICE:  RelationIdBuildRelation: smgropen(pg_shadow): Permission denied
> NOTICE:  mdopen: couldn't open /var/lib/pgsql/pg_shadow: Permission denied
> NOTICE:  mdopen: couldn't open /var/lib/pgsql/pg_shadow: Permission denied
> psql: FATAL 1:  cannot open relation pg_shadow
> createuser: creation of user "abyte" failed

It appears that you are logged in as "root". I think that you need to
login as "postgres" to do the first "creatuser" command. When PostgreSQL
is first installed, the only valid user is "postgres" and is the
equivalent to UNIX's "root" (superuser). It has been a while, but as I
recall, when I installed PostgreSQL, this is what I had to do. I logged in
as "postgres", did a "creatuser" for my "normal" (non-root) userid. This
userid was allowed to create new users and databases. Since then, I have
used my "normal" userid to do all the PostgreSQL maintenance
activities. You may need to do something slightly different if you have
multiple users. I am the only one using my Linux system at present.

I hope this helps some,
John


os.h

From
"Horst Herb"
Date:
Where is the misterious "os.h" located that is required when I try to use libpq++ ??? It is not included in the 7.02
packages(neither source nor binary packages). There are no problems / error messages when using just libpq.  

The other misteriously missing file seems to be "Makefile.global" when trying to make the examples coming with the
"test"package. 

Did I miss an important README? (Thought I had read them all)

Horst


Re: Cant create new users or databases

From
Tom Lane
Date:
AlphaByte <alan@alphabyte.co.nz> writes:
> NOTICE:  mdopen: couldn't open /var/lib/pgsql/pg_shadow: Permission denied
> NOTICE:  RelationIdBuildRelation: smgropen(pg_shadow): Permission denied

Hmm.  What user is the postmaster running as?  (Look in ps -aux output
if you're not 100% sure.)  What are the permissions on the file
/var/lib/pgsql/pg_shadow, and what userid owns it?

            regards, tom lane

Re: os.h

From
Yury Don
Date:
Horst Herb wrote:
>
> Where is the misterious "os.h" located that is required when I try to use libpq++ ??? It is not included in the 7.02
packages(neither source nor binary packages). There are no problems / error messages when using just libpq. 
>
> The other misteriously missing file seems to be "Makefile.global" when trying to make the examples coming with the
"test"package. 
>
> Did I miss an important README? (Thought I had read them all)
>
> Horst

As I understand os.h should be in postgres include directory and it's
just symlink on proper include file for your os from directory "port"
For example on debian linux it must be in /usr/include/postgresql
directory and it's symlink on .././port/linux.h. But when I made
posgresql-dev debian package from sources I got an error "os.h: now such
file ..." Therefore I've created package without this file and then
after installation I've copied file src/include/port/linux.h from
postgresql sources into /usr/include/postgresql/os.h.
So if the file os.h is absent in postgresql include directory on your
system take proper include file from src/include/port from postgresql
sources and copy it as os.h

--
Sincerely yours,
Yury

Re: os.h

From
John McKown
Date:
On Sun, 17 Sep 2000, Horst Herb wrote:

> Where is the misterious "os.h" located that is required when I try to
>use libpq++ ??? It is not included in the 7.02 packages (neither source
>nor binary packages). There are no problems / error messages when using
>just libpq.
>
> The other misteriously missing file seems to be "Makefile.global" when
>trying to make the examples coming with the "test" package.
>
> Did I miss an important README? (Thought I had read them all)
>
> Horst
>
I have that file in the /usr/include/pgsql/ directory. I run RedHat and
installed PostgreSQL from the RPMs. That file is in
postgresql-devel-7.0.2-2 . I don't know where it might be in some other
distribution (such as the tarball).

John


Re: Cant create new users or databases

From
AlphaByte
Date:
On Sun, 17 Sep 2000, John McKown wrote regarding "Re: [GENERAL] Cant create new users or databases":
>
> Well, now it looks as if you are logged in as "abyte". You need to be
> logged in as "postgres" in order to start the daemon and to do the
> "createuser". Please forgive my faulty memory, but I think that you need
> to do this:
>
> 1) Login as "postgres"

And so the plot thickens. In order to login as postgres you
have to specify the data environment otherwise it says this:

postgres does not know where to find the database system
data.  You must specify the directory that contains the
database system either by specifying the -D invocation
option or by setting the PGDATA environment variable.

Which is what the command I used was supposed to do, ie:

postgres -D /var/lib/pgsql

But I don't know if my syntax is wrong there, but that is
where postmaster.pid is though.

> 2) Issue the following commands at the prompt (starts
the backend): >    export PGDATA=/var/lib/pgsql
>    mkdir -p $PGDATA
>    /usr/bin/initdb --pglib=/var/lib/pgsql --pgdata=/var/lib/pgsql/data
>    /usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster start >/dev/null 2>&1

Should I include all this when I login for the first time
perhaps?

> 3) At this point, the database backend should be up.
> 4) Now issue the commands (you're still logged in as "postgres"!)
>    createuser abyte
> In this command, answer "y" to the two questions about can the user create
> databases & users. This will allow you to use "abyte" as your normal
> PostgreSQL administrator.
> 5) Logoff of "postgres" and login as "abyte"
> 6) Issue the command: "initdb". This will create the "abyte" database with
> no tables in it.
> 7) You should now be able to issue the "pgsql" command and do whatever.
>
> Oh, one thing that I did was (as "root") change the /etc/profile to
> contain the two lines:
>
> export PGLIB=/var/lib/pgsql
> export PGDATA=/var/lib/pgsql/data
>
OK, I'll try that but first I just want to login first.

>
> Oh, you might get more and better information if you also post your
> questions to one of the pgsql-hackers@postgresql.org or the
> psql-general@postgresql.org mailing lists. Feel free to
> continue to email me if you want, but I'm not a real PostgreSQL heavy
> (yet).

Thanks anyway, any help is appreciated at this point :0)

Alan

--
AlphaByte: PO Box 1941, Auckland, New Zealand
Specialising in:Graphic Design, Education and Training,
Technical Documentation, Consulting.
http://www.alphabyte.co.nz

Re: Cant create new users or databases

From
AlphaByte
Date:
On Mon, 18 Sep 2000, Tom Lane wrote regarding "Re: [GENERAL] Cant create new users or databases":
> pg_shadow certainly should not be owned by root.  It should be owned by
> the postgres user (ie, whoever the postmaster is running as, which you
> didn't say).

pg_shadow is now owned by postgres and so are the other
files in /var/lib/pgsql.

This time when I type postgres -D /var/lib/pgsql I get:

>Can't open pid file: /var/lib/pgsql/postmaster.pid
>Please check the permission and try again.

I have also checked the ownership of the folder, which is
also postgres. So I guess if nothing else will work then I
can only assume that PGSQL is pretty much broken and doesnt
go.

Thanks for your help anyway, at least it showed that a
couple of things needed to be put right

 --
AlphaByte: PO Box 1941, Auckland, New Zealand
Specialising in:Graphic Design, Education and Training,
Technical Documentation, Consulting.
http://www.alphabyte.co.nz

RE: Cant create new users or databases

From
"Robert D. Nelson"
Date:
>This time when I type postgres -D /var/lib/pgsql I get:
>
>>Can't open pid file: /var/lib/pgsql/postmaster.pid
>>Please check the permission and try again.
>
>I have also checked the ownership of the folder, which is
>also postgres. So I guess if nothing else will work then I

Check the permissions of /var and /var/lib too - without o+x bits, postgres
can't get as far as /var/lib/pgsql, can it?


Rob Nelson
rdnelson@co.centre.pa.us