skip to Main Content

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


  1. Try:
    su -l <username> to switch user account and then run initdb -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

      Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor pr>
      Active: active (exited) since Sat 2023-02-18 23:01:05 IST; 7min ago
      
    • To get into postgres shell: sudo su - postgres, and type the password.

    • To get into psql shell: psql -p <port>.

    Login or Signup to reply.
  2. This worked for me, try the following commads :

    su --login faruukh

    cd /usr/local/pgsql/bin/

    ./initdb -D /usr/local/pgsql/bin/psql/data

    Here’s the reference for initdb

    Login or Signup to reply.
  3. I reproduced the error that you encountered:-

    ~/Downloads$ initdb
    The files belonging to this database system will be owned by user "capnspek".
    This user must also own the server process.
    
    The database cluster will be initialized with locale "en_IN".
    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
    

    Adding a ./data at the end of the command successfully initializes the database cluster.

    ~/Downloads$ initdb ./data
    The files belonging to this database system will be owned by user "capnspek".
    This user must also own the server process.
    
    The database cluster will be initialized with locale "en_IN".
    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.
    
    creating directory ./data ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting default timezone ... Asia/Kolkata
    selecting dynamic shared memory implementation ... posix
    creating configuration files ... ok
    running bootstrap script ... ok
    performing post-bootstrap initialization ... ok
    syncing data to disk ... ok
    
    WARNING: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the option -A, or
    --auth-local and --auth-host, the next time you run initdb.
    
    Success. You can now start the database server using:
    
        pg_ctl -D ./data -l logfile start
    

    Hopefully, that solves your issue.
    Read more about initdb here.
    Follow the documentation from here.

    Login or Signup to reply.
  4. try these commands

    wget https://ftp.postgresql.org/pub/source/v11.18/postgresql-11.18.tar.gz && tar -xvf postgresql-11.18.tar.gz && rm -f postgresql-11.18.tar.gz
    
        cd postgresql-11.18
        ./configure --enable-debug --enable-cassert --prefix=$(path) CFLAGS="-ggdb -Og -fno-omit-frame-pointer"
    
         
     
    
     make
    make install
          export PATH=/usr/local/pgsql/bin/:$PATH
        export PGDATA=/usr/local/pgsql/bin/data
        Initdb
    
        pg_ctl start -l log
     
    
    psql postgres
    
        
    
    Login or Signup to reply.
  5. Try running the following command.

    pg_ctl -D "dbname" -l logfile start
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search