Termux-packages: Unable to start psql?

Created on 4 Jul 2017  路  8Comments  路  Source: termux/termux-packages

I have installed postgres & contrib packages. psql fails with

otus:/ # psql
psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/data/data/com.termux/files/usr/tmp//.s.PGSQL.5432"?

Most helpful comment

  1. Create database directory:
mkdir ~/db
initdb ~/db
  1. Start postgresql server:
pg_ctl -D ~/db start
  1. Create database with specified name:
createdb mydb
  1. Connect to it with psql:
psql mydb

Important: avoid usage of root shell as it will probably break $PREFIX and introduce further issues.

All 8 comments

Did you start the server?
You need to initdb <path where to store data> to create database skeleton files, then pg_ctl -D <path from previous initdb> start to start the server

@vishalbiswas Thanks for the help. Without root, I am not able to run initdb. With root it fails with

athene:/ # /data/data/com.termux/files/usr/bin/initdb /data/local/tmp/pg                                                                           
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.

cannot run initdb? what's the error? you shouldn't pass /data/local/tmp
instead use something like $PREFIX/usr/var/postgresql

What is the value of $PREFIX? It is not set in adb shell?

Its /data/data/com.termux/files/usr
But it won't be accessible from adb shell either. Is there a reason to not use termux's cli?

When I open termux, it fails with

photo6278203762900314049

Can you reinstall termux?

  1. Create database directory:
mkdir ~/db
initdb ~/db
  1. Start postgresql server:
pg_ctl -D ~/db start
  1. Create database with specified name:
createdb mydb
  1. Connect to it with psql:
psql mydb

Important: avoid usage of root shell as it will probably break $PREFIX and introduce further issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

reggi picture reggi  路  4Comments

Cyb3rD3m0n picture Cyb3rD3m0n  路  3Comments

bkdwt picture bkdwt  路  3Comments

Wetitpig picture Wetitpig  路  3Comments

neitsab picture neitsab  路  3Comments