Drwooi Poipoi
Drwooi Poipoi

Reputation: 191

Postgres can not change directory in Ubuntu 14.04

I am trying to create and use a new database in postgres. When I try to load the db with the command below:

sudo -u postgres psql

I get this error.

could not change directory to "/home/laptop/Dropbox/js/hw/Has-Many-Relationships": Permission denied psql (9.3.13) Type "help" for help.

I have tried to change the folder permissions in nautilus as root. This command will work as expected when the folder is changed to root (cp and cd /) Any ideas?

Upvotes: 14

Views: 24377

Answers (1)

Jesse Adelman
Jesse Adelman

Reputation: 471

It sounds like your shell's CWD (Current Working Directory) is

/home/laptop/Dropbox/js/hw/Has-Many-Relationships

and that the 'postgres' user does not have access to that directory.

However, by the next line, you DO seem to be able to talk to a running PostgreSQL server, though you don't share the next line.

This may be helpful if this is a "completely throwaway" database instance on your local machine (laptop):

http://johnmee.com/how-to-reinstall-postgresql-on-ubuntu

This method will completely purge all postgres packages (not just the virtual package) and allow you to start over with a fresh install of PostgreSQL.

Once you've got a clean install of PostgreSQL, try this, as root:

# cd ~postgres/
# sudo -u postgres psql

And see if the error does not repeat.

Hope that helps!

Upvotes: 22

Related Questions