Linux 为什么在PostgreSQL中使用标志password/locahost时出现权限被拒绝错误?
数据库检测器存在,由psql中的\l验证。 通过从pg_user;中选择*验证用户postgres是否存在 1测试[已解决] 我跑 但是得到Linux 为什么在PostgreSQL中使用标志password/locahost时出现权限被拒绝错误?,linux,postgresql,shell,file-permissions,Linux,Postgresql,Shell,File Permissions,数据库检测器存在,由psql中的\l验证。 通过从pg_user;中选择*验证用户postgres是否存在 1测试[已解决] 我跑 但是得到 could not change directory to "/home/masi/det": Permission denied 同时获得用户表的正确输出 Fabrico回答和评论中的解决方案,即重新启动shell;以前运行标志-密码会导致奇怪的行为 2测试[已解决] 其他奇怪的测试。我跑 sudo -u postgres psql
could not change directory to "/home/masi/det": Permission denied
同时获得用户表的正确输出
Fabrico回答和评论中的解决方案,即重新启动shell;以前运行标志-密码会导致奇怪的行为
2测试[已解决]
其他奇怪的测试。我跑
sudo -u postgres psql detector --password -h localhost -c 'SELECT * FROM pg_user;'
虽然我是本地主机,但它给出了以下内容
psql: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
Fabricio回答和评论中的解决方案,即重新启动shell,不要在sudo中使用标志-密码。
不要在sudo中使用标志-h localhost
为什么会出现“权限被拒绝”错误?启动psql命令时,您处于/home/masi/det_78_2015中。由于启动命令的用户是postgres,因此不允许查看您所在的当前主目录。这就是为什么该命令成功,但它抛出了一个有关目录权限的错误
Postgres用户在系统中有主目录吗?对不起,只是在正文中输入了错误。我在正确的位置。主目录应该在哪里?我没有设置任何内容。这不会真正影响查询。它只是告诉你,一旦命令以postgres的形式执行,它就不能更改到当前的目录。你运行的是什么系统?Debian 8.1,类似于Ubuntu。根据问题,你有两个不同的问题。Te目录问题不多。问题在于身份验证。
psql: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"