su postgres 在 Mac 作業系統中不起作用

su postgres 在 Mac 作業系統中不起作用

我在嘗試:

su postgres

輸入 root 密碼,但收到: 抱歉,我嘗試了以下操作:

sudo -u postgres

但收到:無法辨識目前目錄:權限被拒絕

當我嘗試時

 sudo su postgres

收到:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied

在 pg_hba.conf 中

local   all             all                                     trust

答案1

  • su postgres

需要用戶的密碼postgres,而不是root

  • sudo -u postgres

Permission denied

找到了解決方法https://trac.macports.org/ticket/18024

cd /tmp ; sudo -u postgres

因此,使用者postgres在執行命令的 CWD 中沒有權限sudo

  • pg_hba.conf

su與/無關sudo,它用於來自 psql 或資料庫客戶端的資料庫連接。

相關內容