PostgreSQL: .psql_history to /dev/null

99封情书 提交于 2019-12-11 00:27:00

问题


Rather than apply a \set HISTFILE command for every possible connection, we would like to have no .psql_history at all. However, psql seems to dislike that:

% ln -s /dev/null ~/.psql_history
% psql
psql (8.4.8)
postgres=# select version();
...
postgres=# \q
could not save history to file "~/.psql_history": Not owner

There are folks out there willing to patch the source to get a fix but we prefer to be on a vanilla binary installation whenever possible: to us, this isn't worth the hack.

To clarify: we don't want anything kept in this default filename, regardless of whether or not the user on this machine remembers (or knows) what options to pass.

Any suggestions?


回答1:


You can use -n (or synonym --no-readline) switch in psql command:

Do not use readline for line editing and do not use the history. This can be useful to turn off tab expansion when cutting and pasting.

EDIT:

As another way you can create ~/.psqlrc file that contains \set HISTFILE /dev/null. With that psql doesn't create unwanted .psql_history file at all.



来源:https://stackoverflow.com/questions/6654121/postgresql-psql-history-to-dev-null

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!