I am trying to install Apache age and Postgres from source code but i am not able to start postgres Server
`
The files belonging to this database system will be owned by user "faruukh".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
initdb: could not access directory "/usr/local/pgsql/bin/psql": Not a directory
faruukh@ubuntu:~$ sudo chown -R farrukh /usr/local/pgsql/
chown: invalid user: ‘farrukh’
faruukh@ubuntu:~$ sudo chown -R faruukh /usr/local/pgsql/
faruukh@ubuntu:~$ which psql
/usr/local/pgsql/bin//psql
faruukh@ubuntu:~$ ls /usr/local/pgsql/bin/
clusterdb data ecpg pg_basebackup pg_controldata pg_dumpall pg_recvlogical pg_rewind pg_upgrade postgres reindexdb
createdb dropdb initdb pgbench pg_ctl pg_isready pg_resetwal pg_test_fsync pg_verify_checksums postmaster vacuumdb
createuser dropuser pg_archivecleanup pg_config pg_dump pg_receivewal pg_restore pg_test_timing pg_waldump psql
faruukh@ubuntu:~$ export PATH=/usr/local/pgsql/bin//psql:$PATH
faruukh@ubuntu:~$ export PGDATA=/usr/local/pgsql/bin//psql/data
faruukh@ubuntu:~$ sudo chown -R faruukh /usr/local/pgsql/
faruukh@ubuntu:~$ initdb
The files belonging to this database system will be owned by user "faruukh".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
initdb: could not access directory "/usr/local/pgsql/bin/psql/data": Not a directory
faruukh@ubuntu:~$ sudo initdb
sudo: initdb: command not found
faruukh@ubuntu:~$ export PGDATA=/usr/local/pgsql/bin//psql/data
faruukh@ubuntu:~$
faruukh@ubuntu:~$
faruukh@ubuntu:~$
faruukh@ubuntu:~$
faruukh@ubuntu:~$
faruukh@ubuntu:~$ which psql
/usr/local/pgsql/bin//psql
faruukh@ubuntu:~$ pg_ctl
pg_ctl pg_ctlcluster
faruukh@ubuntu:~$ pg_ctl
pg_ctl pg_ctlcluster
faruukh@ubuntu:~$ pg_ctl
pg_ctl pg_ctlcluster
faruukh@ubuntu:~$ pg_ctl start log -l
pg_ctl: option requires an argument -- 'l'
Try "pg_ctl --help" for more information.
faruukh@ubuntu:~$ pg_ctl
pg_ctl: no operation specified
Try "pg_ctl --help" for more information.
faruukh@ubuntu:~$
`
```
```[error][1]
Tried following commands
cd postgresql-12.0
which psql
ls /usr/local/pgsql/bin/
export PATH=/usr/local/pgsql/bin/:$PATH
export PGDATA=/usr/local/pgsql/bin/data
sudo chown -R faruukh /usr/local/pgsql/
5
Answers
Try:
su -l <username>
to switch user account and then runinitdb -D <path to where new db cluster should be stored>
For me
which psql
gives/usr/bin/psql
.To start postgres SQL:
sudo systemctl start postgresql@12-main
(if pg version 12 is installed)To check if postgres is running:
service postgresql status
To get into postgres shell:
sudo su - postgres
, and type the password.To get into psql shell:
psql -p <port>
.This worked for me, try the following commads :
Here’s the reference for initdb
I reproduced the error that you encountered:-
Adding a
./data
at the end of the command successfully initializes the database cluster.Hopefully, that solves your issue.
Read more about initdb here.
Follow the documentation from here.
try these commands
Try running the following command.
Additionally, I think you should check whether your PostgreSQL and age versions are compatible with each other and try setting up them again by following the steps properly.
This youtube link is a good tutorial for setting up.