我需要设置以下env变量,以便我可以使用PostgreSQL的数据库程序
export PGDATA="/home/masi/postgres/var" export PGPORT="12428"我知道可以通过将文件添加到.zshrc来解决问题。 但是,我不确定这是否是正确的路要走。
你如何添加env变量?
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?
最满意答案
您只需要在启动服务器的脚本中设置PGDATA变量。 客户端只关心端口。
如果您必须在非标准端口上运行端口值,则必须设置端口值。 我假设你有一个很好的理由不只是在默认端口上运行它? 如果你确实在默认端口(5432)上运行它,那么它完全可以在没有任何参数的情况下运行。
如果您在其他端口上运行它,则应进行两项更改:
在postgresql.conf中,将port = value设置为所需的新端口,然后重新启动数据库服务器。 在django的settings.py中,将DATABASE_PORT值设置为所需的新端口。你绝对不需要为这些简单的配置选项使用环境变量 - 避免它们会让你的生活更轻松。
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:
In postgresql.conf, set the port= value to the new port you want, and restart the database server. In your settings.py in django, set the DATABASE_PORT value to the new port you want.You should definitely not need to use environment variables for simple configuration options like these - avoiding them will make your life easier.
更多推荐
发布评论