Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is psql client history kept? (~/.psql_history non-existent!)

A password is visible in my psql prompt (by pushing up arrow to view previous inputted commands). So I would like to delete that entry from the psql client.

Other resources(1, 2) claim that psql client history is kept in is a ~/.psql_history file, however this file is simply not there. (it's not in .bash_history either)

So there must be another file where the history of psql prompt is kept, any ideas where?

I log in to my prompt like this sudo -u postgres psql my_db

Note: I am working on Ubuntu 12.04

like image 970
Bentley4 Avatar asked Jul 29 '13 13:07

Bentley4


People also ask

How do I clear postgres history?

Please check on the /home/user/. psql_history , then open the file if we want we can clear all the commands or the necessary commands and save the file.

Where is psql EXE located?

open command prompt first ( Winkey+R ), then type C:\Program Files\PostgreSQL\10\bin\psql.exe , then press enter and type in password.

Is psql and PostgreSQL same?

psql is a terminal-based front-end to PostgreSQL. It enables you to type in queries interactively, issue them to PostgreSQL, and see the query results.


1 Answers

When you use:

sudo -u postgres psql my_db 

you run psql as the (Linux) user postgres, therefor the .psql_history file is in the home directory of the postgres user (e.g. /home/postgres/.psql_history), not in the home directory of the user you originally logged in with.

In some installations, the location of the postgres user's home directory is /var/lib/postgresql. You can check this by running:

grep postgres /etc/passwd | cut -d ':' -f 6 
like image 63
a_horse_with_no_name Avatar answered Oct 03 '22 02:10

a_horse_with_no_name