[英]postgreSQL error initdb: command not found
我正在使用 linuxbrew 在 ubuntu 上安裝 postgresql:
brew install postgresql
它似乎工作正常,但在那之后因為我第一次嘗試創建數據庫時正在安裝 PostgreSQL:
initdb /usr/local/var/postgres -E utf8
但它返回為:
initdb: command not found
我嘗試使用sudo but that doesn't helped
運行locate initdb
它應該給你選擇的列表。 像:
MacBook-Air:~ vao$ locate initdb
/usr/local/Cellar/postgresql/9.5.3/bin/initdb
/usr/local/Cellar/postgresql/9.5.3/share/doc/postgresql/html/app-initdb.html
/usr/local/Cellar/postgresql/9.5.3/share/man/man1/initdb.1
/usr/local/Cellar/postgresql/9.6.1/bin/initdb
/usr/local/Cellar/postgresql/9.6.1/share/doc/postgresql/html/app-initdb.html
/usr/local/Cellar/postgresql/9.6.1/share/man/man1/initdb.1
/usr/local/bin/initdb
/usr/local/share/man/man1/initdb.1
所以在我的情況下我想跑
/usr/local/Cellar/postgresql/9.6.1/bin/initdb
如果您沒有安裝mlocate,請安裝或使用
sudo find / -name initdb
對SuperUser上的類似問題有一個很好的答案。
簡而言之:
initdb
來創建一個。 pg_createcluster
來代替initdb
,后者不包含在PATH
,以阻止最終用戶直接使用它。 如果您只是嘗試創建數據庫而不是數據庫集群,請使用createdb
命令。
我有同樣的問題,在這里找到答案。
Ubuntu路徑是
/usr/lib/postgresql/9.6/bin/initdb
編輯:對不起,艾哈邁德問linuxbrew,我說的是Ubuntu。 我希望這個答案有助於某人。
我有一個類似的問題,因為brew install postgresql
沒有正確鏈接 postgres。 我的解決方案是運行:
brew link --overwrite postgresql
您可以添加 PATH 以從任何位置運行
sudo nano ~/.profile
里面 nano go 到最后並添加以下內容
# set PATH so it includes user's private bin if it exists
if [ -d "/usr/lib/postgresql/14/bin/" ] ; then
PATH="/usr/lib/postgresql/14/bin/:$PATH"
fi
並配置替代方案
sudo update-alternatives --install /usr/bin/initdb initdb /usr/lib/postgresql/14/bin/initdb 1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.