Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 480
Drwooi Poipoi Avatar asked Jul 20 '16 01:07

Drwooi Poipoi


People also ask

Where is Postgres data directory Ubuntu?

You can now locate the Postgres Database files by navigating the directory that was displayed. However, the PostgreSQL configuration directory in Ubuntu is located in /etc/postgresql/10/main .


1 Answers

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!

like image 175
Jesse Adelman Avatar answered Oct 06 '22 11:10

Jesse Adelman