Thread: createdb -- alternate locations
Hello: Novice, just installed PGSQL 7.0 on Redhat 6.1. Everything went smoothly with initial installation and db setup. However, I've run into some problems subsequently. To keep it simple, here is a specific problem. Attempting to create a database in an alternate location, I went through the following steps as the superuser (postgres): mkdir /home/postgres/testdata export PGDATA2=/home/postgres/testdata initlocation PGDATA2 createdb testdb -D 'PGDATA2' the last command failed with this error: "The database path 'PGDATA2' in invalid. This may be due to a character that is not allowed or because the chosen path isn't permitted for databases" I also tried createdb -D 'PGDATA2' testdb, same result. Any ideas what I'm doing wrong? Thanks, J.R. Belding jrbelding@yahoo.com
Try createdb -D $PGDATA2 testdb At 11:26 PM 5/25/00, J.R. wrote: > Hello: > >Novice, just installed PGSQL 7.0 on Redhat 6.1. > >Everything went smoothly with initial installation and db setup. >However, I've run into some problems subsequently. > >To keep it simple, here is a specific problem. Attempting to create a >database in an alternate location, I went through the following steps as >the superuser (postgres): > >mkdir /home/postgres/testdata >export PGDATA2=/home/postgres/testdata >initlocation PGDATA2 >createdb testdb -D 'PGDATA2' > >the last command failed with this error: >"The database path 'PGDATA2' in invalid. This may be due to a character >that is not allowed or because the chosen path isn't permitted for >databases" > >I also tried createdb -D 'PGDATA2' testdb, same result. > > >Any ideas what I'm doing wrong? > >Thanks, >J.R. Belding >jrbelding@yahoo.com > > >
> Try createdb -D $PGDATA2 testdb I will be surprised if that works. The initlocation manual says -D can be a path or an environment variable which will be referenced. Not sure what that means. > > At 11:26 PM 5/25/00, J.R. wrote: > > Hello: > > > >Novice, just installed PGSQL 7.0 on Redhat 6.1. > > > >Everything went smoothly with initial installation and db setup. > >However, I've run into some problems subsequently. > > > >To keep it simple, here is a specific problem. Attempting to create a > >database in an alternate location, I went through the following steps as > >the superuser (postgres): > > > >mkdir /home/postgres/testdata > >export PGDATA2=/home/postgres/testdata > >initlocation PGDATA2 > >createdb testdb -D 'PGDATA2' > > > >the last command failed with this error: > >"The database path 'PGDATA2' in invalid. This may be due to a character > >that is not allowed or because the chosen path isn't permitted for > >databases" > > > >I also tried createdb -D 'PGDATA2' testdb, same result. > > > > > >Any ideas what I'm doing wrong? > > > >Thanks, > >J.R. Belding > >jrbelding@yahoo.com > > > > > > > > -- Bruce Momjian | http://www.op.net/~candle pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
> Try createdb -D $PGDATA2 testdb > > At 11:26 PM 5/25/00, J.R. wrote: > > Hello: OK, I see this in the code, so it seems $PGDATA2 and 'PGDATA2' are the same: if [ "$?" -ne 0 -a ! -d "$Location" ]; then PGALTDATA=`printenv $Location 2> /dev/null` if [ -z "$PGALTDATA" ]; then echo "$CMDNAME: environment variable $Location not set" exit 1 fi Does everyone have printenv? I sure hope so. -- Bruce Momjian | http://www.op.net/~candle pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
On Thu, 25 May 2000 23:10:49 -0400 (EDT) Bruce Momjian wrote: > Does everyone have printenv? I sure hope so. Possibly not, since it's not part of UNIX98 (the "Single Unix Specification, version 2"). I don't have a POSIX standard handy right now but I don't think it is specified there either. On the other hand, my NetBSD manual page says printenv was introduced in BSD 3.0, so perhaps it's everywhere even if non-standard, which would be typically Unix! If someone does find a platform that is missing printenv it's easy enough to change that code to use env and grep instead. Regards, Giles
"J.R." wrote: > > Hello: > > Novice, just installed PGSQL 7.0 on Redhat 6.1. > > Everything went smoothly with initial installation and db setup. > However, I've run into some problems subsequently. > > To keep it simple, here is a specific problem. Attempting to create a > database in an alternate location, I went through the following steps as > the superuser (postgres): > > mkdir /home/postgres/testdata > export PGDATA2=/home/postgres/testdata > initlocation PGDATA2 > createdb testdb -D 'PGDATA2' > > the last command failed with this error: > "The database path 'PGDATA2' in invalid. This may be due to a character > that is not allowed or because the chosen path isn't permitted for > databases" > does anybody actually read the mailing lists? i think this was covered last week. it's almost certainly that the postmaster was started before the environment variable was declared. the postmaster needs to be restarted with the environment variable set in order for this to work. this should probably be put in bold print in the docs or in a faq (if i recall correctly, i think it's mentioned there). it'd even be a good use of annotable documentation, too. it seems like there are a lot of novice mistakes like that that are common & very frustrating to new users & that annotated docs or expanded faqs would be really helpful. jeff
J.R. writes: > Hello: > > Novice, just installed PGSQL 7.0 on Redhat 6.1. > > Everything went smoothly with initial installation and db setup. > However, I've run into some problems subsequently. > > To keep it simple, here is a specific problem. Attempting to create a > database in an alternate location, I went through the following steps as > the superuser (postgres): > > mkdir /home/postgres/testdata > export PGDATA2=/home/postgres/testdata > initlocation PGDATA2 > createdb testdb -D 'PGDATA2' > > the last command failed with this error: > "The database path 'PGDATA2' in invalid. This may be due to a character > that is not allowed or because the chosen path isn't permitted for > databases" > > I also tried createdb -D 'PGDATA2' testdb, same result. > > > Any ideas what I'm doing wrong? What a coincidence; I just asked about this last week. What you've got is right, but before you can createdb, you've got to stop and restart the postmaster with "PGDATA2=/home/postgres/testdata" in its environment. Good luck... -- Richard Kuhns rjk@grauel.com PO Box 6249 Tel: (765)477-6000 \ 100 Sawmill Road x319 Lafayette, IN 47903 (800)489-4891 /
> J.R. writes: > > Hello: > > > > Novice, just installed PGSQL 7.0 on Redhat 6.1. > > > > Everything went smoothly with initial installation and db setup. > > However, I've run into some problems subsequently. > > > > To keep it simple, here is a specific problem. Attempting to create a > > database in an alternate location, I went through the following steps as > > the superuser (postgres): > > > > mkdir /home/postgres/testdata > > export PGDATA2=/home/postgres/testdata > > initlocation PGDATA2 > > createdb testdb -D 'PGDATA2' > > > > the last command failed with this error: > > "The database path 'PGDATA2' in invalid. This may be due to a character > > that is not allowed or because the chosen path isn't permitted for > > databases" > > > > I also tried createdb -D 'PGDATA2' testdb, same result. > > > > > > Any ideas what I'm doing wrong? > > What a coincidence; I just asked about this last week. What you've got is > right, but before you can createdb, you've got to stop and restart the > postmaster with "PGDATA2=/home/postgres/testdata" in its environment. OK, I have udpated initlocation manual pages to mention stop/restart of postmaster and that this must be defined everytime the postmaster starts. Do we allow absolute paths in initlocation anymore? I am not sure. -- Bruce Momjian | http://www.op.net/~candle pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
On Thu, 25 May 2000, J.R. wrote: > mkdir /home/postgres/testdata > export PGDATA2=/home/postgres/testdata > initlocation PGDATA2 > createdb testdb -D 'PGDATA2' You need to set the PGDATA2 environment variable in the environment of the postmaster. That is, shut it down, export xxx, restart. Not ideal, I know, but we're working on it. > > the last command failed with this error: > "The database path 'PGDATA2' in invalid. This may be due to a character > that is not allowed or because the chosen path isn't permitted for > databases" -- Peter Eisentraut Sernanders väg 10:115 peter_e@gmx.net 75262 Uppsala http://yi.org/peter-e/ Sweden