I need to set up the following env variables such that I can a database program which use PostgreSQL
export PGDATA="/home/masi/postgres/var"
export PGPORT="12428"
I know that the problem may be solved by adding the files to .zshrc.
However, I am not sure whether it is the right way to go.
How can you add env variables?
You only need to set the PGDATA variable in the script that starts the server. The client only cares about the port.
You do have to set the port value if you must run it on a non-standard port. I assume you have a good reason to not just run it on the default port? If you do run it on the default port (5432), it will just work without any parameters for it at all.
If you are running it on a different port, you should make two changes:
You should definitely not need to use environment variables for simple configuration options like these – avoiding them will make your life easier.