postgresql Postgres createdb:找不到命令 Mac OS 终端
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23250886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Postgres createdb: command not found Mac OS Terminal
提问by user3315620
After su postgres
and typing of my password in my macOS terminal, it shows bash-3.2$
之后su postgres
我在我的MacOS密码的输入端,它显示bash-3.2$
What when I type command like createdb
, it says:
当我输入类似的命令时createdb
,它说:
bash: createdb: command not found
bash: createdb: 命令未找到
I googled and it says "either PostgreSQL was not installed at all or your shell's search path was not set to include it."
我用谷歌搜索,它说“要么根本没有安装 PostgreSQL,要么你的 shell 的搜索路径没有设置为包含它。”
How can I fix this?
我怎样才能解决这个问题?
回答by dr jimbob
Before typing in su postgres
type in which createdb
which will tell you what the path is for createdb. For example if which returns /usr/local/bin/createdb
, you would add that path to your environmental variable $PATH
by typing export PATH=$PATH:/usr/local/bin
in the command line once you type su postgres
. Then you can run createdb.
在输入su postgres
type in which createdb
which之前,它将告诉您 createdb 的路径是什么。例如,如果 which 返回/usr/local/bin/createdb
,您将在$PATH
输入export PATH=$PATH:/usr/local/bin
后通过在命令行中输入 来将该路径添加到您的环境变量中su postgres
。然后你可以运行createdb。
Alternatively, you can just specify the full path in the command line /usr/local/bin/createdb
. If you need to do this often, you can add the line to change the PATH
variable in ~/.bash_profile
.
或者,您可以只在命令行中指定完整路径/usr/local/bin/createdb
。如果您需要经常这样做,您可以PATH
在~/.bash_profile
.