This cheatsheet is for the following video that shows how to Install and Run the PostgreSQL Database server on your Andriod Phone. Watch this video for a complete Demo/Solution: https://youtu.be/7edutr-ALdc
- Google PlayStore: https://play.google.com/store/apps/details?id=com.termux
- Fdroid PlayStore(Recommended): https://f-droid.org/en/packages/com.termux
- Github (latest builds): https://github.com/termux/termux-app/releases
Once termux is installed open it and use the shell for below commands
apt update && apt install postgresql
If receiving the termux repo under maintenance error watch this video for a fix: https://youtu.be/kaCkPTX3p2E
mkdir ./postgres && initdb ./postgres
this directory stores all the postgresql data and setting files.
pg_ctl -D ./postgres start
# Login:
psql -d postgres
# Quit:
\q
pg_ctl -D ./postgres stop
You can optionally create aliases to start and stop the DB server and put them in your .bashrc/.zshrc files:
alias pgstart='pg_ctl -D ./postgres start' >> ~/.bashrc
alias pgstop='pg_ctl -D ./postgres stop' >> ~/.bashrc
Then use this aliases pgstart
to start the Postgres Server
& pgstop
to stop the Postgres Server.
You can additionally create the more databases and DB users directly from bash shell:
# Creating additonal DB:
createdb db_name
# Creating additional DB user:
createuser --superuser --pwprompt pg_user
Enjoy!!