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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:25:15  来源:igfitidea点击:

Postgres createdb: command not found Mac OS Terminal

macospostgresql

提问by user3315620

After su postgresand 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 postgrestype in which createdbwhich 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 $PATHby typing export PATH=$PATH:/usr/local/binin the command line once you type su postgres. Then you can run createdb.

在输入su postgrestype in which createdbwhich之前,它将告诉您 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 PATHvariable in ~/.bash_profile.

或者,您可以只在命令行中指定完整路径/usr/local/bin/createdb。如果您需要经常这样做,您可以PATH~/.bash_profile.