Thread: initdb can't init the database
Hi team,
I use the source to install the postgresql 15.3 (Fedora Linux 37), I create a install.sh as this:
install.sh:
sudo rm -r /home/postgres/pgsql
sudo mkdir /home/postgres/pgsql
sudo rm -r /home/postgres/pgsql/lib
sudo mkdir /home/postgres/pgsql/lib
./configure --prefix=/home/postgres/pgsql/bin --exec-prefix=/home/postgres/pgsql/lib --enable-debug --enable-coverage --enable-dtrace --enable-cassert --enable-profiling
sudo make install
sudo useradd -m postgres
sudo passwd -d postgres
make clean
Then, I start to execute this shell script:
[beginnerc@bogon postgresql-15.3]$ ./install.sh
[sudo] beginnerc's passwod:
[sudo] beginnerc's passwod:
...
[beginnerc@bogon postgresql-15.3]$ su postgres
bash-5.1$ ./initdb
initdb: error: no data directory specifiedinitdb: hint: You must identify the directory where the data for this database system will reside. Do this with either the invocation option -D or the environment variable PGDATA.
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/thread.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/strerror.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/snprintf.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/quotes.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pqsignal.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pgstrsignal.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pgstrcasecmp.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pgmkdirp.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pgcheckdir.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/path.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/chklocale.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/strlcpy.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/logging.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/sprompt.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/restricted_token.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/fe_memutils.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/wait_error.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/username.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/stringinfo.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/string.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/rmtree.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/psprintf.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/pgfnames.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/pg_prng.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/pg_get_line.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/kwlookup.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/keywords.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/file_utils.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/file_perm.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/exec.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/encnames.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/fe_utils/string_utils.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/bin/initdb/localtime.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/bin/initdb/initdb.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/bin/initdb/findtimezone.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/thread_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/strerror_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/snprintf_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pgstrcasecmp_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pg_strong_random_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/noblock_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/inet_net_ntop_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/chklocale_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/strlcpy_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/getpeereid_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/sha2_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/sha1_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/md5_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/hmac_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/cryptohash_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/wchar_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/unicode_norm_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/string_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/scram-common_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/saslprep_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/md5_common_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/link-canary_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/ip_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/encnames_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/base64_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-auth.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/pqexpbuffer.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/libpq-events.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/legacy-pqsignal.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-trace.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-secure.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-protocol3.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-print.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-misc.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-lobj.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-exec.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-connect.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-auth-scram.gcda:Skip
Can someone give me some advice?
Thanks in advance!
2023年6月10日(土) 14:30 Wen Yi <896634148@qq.com>: > > Hi team, > I use the source to install the postgresql 15.3 (Fedora Linux 37), I create a install.sh as this: > > install.sh: > > sudo rm -r /home/postgres/pgsql > sudo mkdir /home/postgres/pgsql > sudo rm -r /home/postgres/pgsql/lib > sudo mkdir /home/postgres/pgsql/lib > ./configure --prefix=/home/postgres/pgsql/bin --exec-prefix=/home/postgres/pgsql/lib --enable-debug --enable-coverage --enable-dtrace--enable-cassert --enable-profiling > sudo make install > sudo useradd -m postgres > sudo passwd -d postgres > make clean > > Then, I start to execute this shell script: > > > [beginnerc@bogon postgresql-15.3]$ ./install.sh > [sudo] beginnerc's passwod: > ... > [beginnerc@bogon postgresql-15.3]$ su postgres > bash-5.1$ ./initdb > initdb: error: no data directory specified > initdb: hint: You must identify the directory where the data for this database system will reside. Do this with eitherthe invocation option -D or the environment variable PGDATA. (...) > Can someone give me some advice? > Thanks in advance! The clue is right there after you execute initdb. You also might want to check the ownership of those directories being created by the script. Regards Ian Barwick
OK. I find where the problem is, thanks very much!
Yours,
Wen Yi
------------------ Original ------------------
From: "Ian Lawrence Barwick" <barwick@gmail.com>;
Date: Sat, Jun 10, 2023 01:54 PM
To: "Wen Yi"<896634148@qq.com>;
Cc: "pgsql-general"<pgsql-general@lists.postgresql.org>;
Subject: Re: initdb can't init the database
>
> Hi team,
> I use the source to install the postgresql 15.3 (Fedora Linux 37), I create a install.sh as this:
>
> install.sh:
>
> sudo rm -r /home/postgres/pgsql
> sudo mkdir /home/postgres/pgsql
> sudo rm -r /home/postgres/pgsql/lib
> sudo mkdir /home/postgres/pgsql/lib
> ./configure --prefix=/home/postgres/pgsql/bin --exec-prefix=/home/postgres/pgsql/lib --enable-debug --enable-coverage --enable-dtrace --enable-cassert --enable-profiling
> sudo make install
> sudo useradd -m postgres
> sudo passwd -d postgres
> make clean
>
> Then, I start to execute this shell script:
>
>
> [beginnerc@bogon postgresql-15.3]$ ./install.sh
> [sudo] beginnerc's passwod:
> ...
> [beginnerc@bogon postgresql-15.3]$ su postgres
> bash-5.1$ ./initdb
> initdb: error: no data directory specified
> initdb: hint: You must identify the directory where the data for this database system will reside. Do this with either the invocation option -D or the environment variable PGDATA.
(...)
> Can someone give me some advice?
> Thanks in advance!
The clue is right there after you execute initdb.
You also might want to check the ownership of those directories being created
by the script.
Regards
Ian Barwick