Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm following this tutorial to set up my postgresql db.

http://inventtheweb.blogspot.ca/2012/05/install-postgresql-for-django.html

After I finish running the CREATE DATABASE command and run \q

I get the following response.

could not save history to file "/var/lib/postgresql/.psql_history": No such file or directory

What exactly is causing this and will this cause me any issues?

More Information: The version of postgresql that is being installed is 9.3 and I'm installing it on Ubuntu Server 14.04 LTS

share|improve this question
up vote 3 down vote accepted

Yes, the PGSQL system user (usually postgres) has its home directory set to /var/lib/postgresql. I'm presuming you installed your database in a different location. Since that directory doesn't exist, the PSQL program cannot access that folder to create its history file. (PSQL is the interactive command line for PGSQL).

Honestly, it's not that big of a deal. That history file is just a list of commands that were executed inside the PSQL interface.

Since you're done installing, I doubt you'll ever see the message again. That is, unless you connect to PSQL using your own account and you continue to get a similar error message. In that case, your HOME variable might be wrong. You're not logged in to your system as postgres are you? If you are planning on using that user interactively (not advised at all), then you'll have to set its HOME directory to some valid folder.

Here are some reference solutions.

share|improve this answer

There is a confirmed bug on Launchpad that affects PostgreSQL on Ubuntu 14.04:

Bug #1334714 - User postgres can't write to /var/lib/postgresql:

(Reported on 2014-06-26, Status: Confirmed)

Bug Description

Unable to write to history log. Seems to be the same problem as bug 32696 which was marked as fixed back in 2006. But, it happens to me too after straight postgress installation on an Ubuntu 14.04 Amazon EC2 instance.

See also:

Bug #32696 - User postgres can't write to /var/lib/postgresql:

(Reported on 2006-02-24, Status: Fix Released)

share|improve this answer

Update postgres' home directory to point to the correct database location.

sudo usermod --home '/path/to/database' postgres

share|improve this answer

If your directory is actually /var/lib/postgres/ then this is actually an easy fix. Just create the .psql_history file in that directory, and then give the postgres user ownership of the file. Even after I did initdb and then created my test database in the /var/lib/postgres/data/ directory, a .psql_history file was not created. For some reason this has to be done manually.

This is with PostgreSQL 9.4.5 on Linux (Arch/Manjaro), installed from the package manager.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.