[英]postgreSQL error initdb: command not found
i was installing postgresql on ubuntu using linuxbrew:我正在使用 linuxbrew 在 ubuntu 上安装 postgresql:
brew install postgresql
it seems to work fine but after that because i was installing PostgreSQL for the first time i tried creating a database:它似乎工作正常,但在那之后因为我第一次尝试创建数据库时正在安装 PostgreSQL:
initdb /usr/local/var/postgres -E utf8
but it returned as:但它返回为:
initdb: command not found
i tried running the command with sudo but that doesn't helped
我尝试使用
sudo but that doesn't helped
run locate initdb
it should give you the list to chose. 运行
locate initdb
它应该给你选择的列表。 smth like: 像:
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
So in my case I want to run 所以在我的情况下我想跑
/usr/local/Cellar/postgresql/9.6.1/bin/initdb
If you don't have mlocate installed, either install it or use 如果您没有安装mlocate,请安装或使用
sudo find / -name initdb
There's a good answer to a similar question on SuperUser . 对SuperUser上的类似问题有一个很好的答案。
In short: 简而言之:
initdb
to create one. initdb
来创建一个。 pg_createcluster
to be used instead of initdb
, with the latter not included in PATH
so as to discourage end users from using it directly. pg_createcluster
来代替initdb
,后者不包含在PATH
,以阻止最终用户直接使用它。 And if you're just trying to create a database, not a database cluster, use the createdb
command instead. 如果您只是尝试创建数据库而不是数据库集群,请使用
createdb
命令。
I had the same problem and found the answer here . 我有同样的问题,在这里找到答案。
Ubuntu path is Ubuntu路径是
/usr/lib/postgresql/9.6/bin/initdb
/usr/lib/postgresql/9.6/bin/initdb
Edit: Sorry, Ahmed asked about linuxbrew, I'm talking about Ubuntu. 编辑:对不起,艾哈迈德问linuxbrew,我说的是Ubuntu。 I Hope this answer helps somebody.
我希望这个答案有助于某人。
I had a similar issue caused by the brew install postgresql
not properly linking postgres.我有一个类似的问题,因为
brew install postgresql
没有正确链接 postgres。 The solve for me was to run:我的解决方案是运行:
brew link --overwrite postgresql
you can add the PATH to run from any location您可以添加 PATH 以从任何位置运行
sudo nano ~/.profile
inside nano go to the end and add the following里面 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
and configure the alternative并配置替代方案
sudo update-alternatives --install /usr/bin/initdb initdb /usr/lib/postgresql/14/bin/initdb 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.