Postgres 无法在 Ubuntu 14.04 中更改目录

Postgres can not change directory in Ubuntu 14.04

我正在尝试在 postgres 中创建和使用新数据库。当我尝试使用以下命令加载数据库时:

sudo -u postgres psql

我收到这个错误。

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

我尝试以 root 身份更改 nautilus 中的文件夹权限。当文件夹更改为根目录(cp 和 cd /)时,此命令将按预期工作。有什么想法吗?

听起来您的 shell 的 CWD(当前工作目录)是

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

并且 'postgres' 用户无权访问该目录。

但是,到下一行,您似乎可以与 运行 PostgreSQL 服务器通信,尽管您不共享下一行。

如果这是您本地计算机(笔记本电脑)上的 "completely throwaway" 数据库实例,这可能会有所帮助:

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

此方法将完全清除所有 postgres 包(不仅仅是虚拟包)并允许您重新安装 PostgreSQL。

全新安装 PostgreSQL 后,以 root 身份尝试此操作:

# cd ~postgres/
# sudo -u postgres psql

并查看错误是否不再重复。

希望对您有所帮助!