[英]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.