initdb can't init the database

Started by Wen Yialmost 3 years ago3 messagesgeneral
Jump to latest
#1Wen 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 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!

#2Ian Lawrence Barwick
barwick@gmail.com
In reply to: Wen Yi (#1)
Re: initdb can't init the database

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 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

#3Wen Yi
896634148@qq.com
In reply to: Ian Lawrence Barwick (#2)
Re: initdb can't init the database

OK. I find where the problem is, thanks very much!

Yours,
Wen Yi

------------------&nbsp;Original&nbsp;------------------
From: "Ian Lawrence Barwick" <barwick@gmail.com&gt;;
Date:&nbsp;Sat, Jun 10, 2023 01:54 PM
To:&nbsp;"Wen Yi"<896634148@qq.com&gt;;
Cc:&nbsp;"pgsql-general"<pgsql-general@lists.postgresql.org&gt;;
Subject:&nbsp;Re: initdb can't init the database

2023年6月10日(土) 14:30 Wen Yi <896634148@qq.com&gt;:
&gt;
&gt; Hi team,
&gt; I use the source to install the postgresql 15.3 (Fedora Linux 37), I create a install.sh as this:
&gt;
&gt; install.sh:
&gt;
&gt; sudo rm -r /home/postgres/pgsql
&gt; sudo mkdir /home/postgres/pgsql
&gt; sudo rm -r /home/postgres/pgsql/lib
&gt; sudo mkdir /home/postgres/pgsql/lib
&gt; ./configure --prefix=/home/postgres/pgsql/bin --exec-prefix=/home/postgres/pgsql/lib --enable-debug --enable-coverage --enable-dtrace --enable-cassert --enable-profiling
&gt; sudo make install
&gt; sudo useradd -m postgres
&gt; sudo passwd -d postgres
&gt; make clean
&gt;
&gt; Then, I start to execute this shell script:
&gt;
&gt;
&gt; [beginnerc@bogon postgresql-15.3]$ ./install.sh
&gt; [sudo] beginnerc's passwod:
&gt; ...
&gt; [beginnerc@bogon postgresql-15.3]$ su postgres
&gt; bash-5.1$ ./initdb
&gt; initdb: error: no data directory specified
&gt; initdb: hint: You must identify the directory where the data for this database system will reside.&nbsp; Do this with either the invocation option -D or the environment variable PGDATA.
(...)
&gt; Can someone give me some advice?
&gt; 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