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

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)