我在安装PostgreSQL时遇到了错误,我使用的是Ubuntu 22。

huangapple go评论68阅读模式
英文:

I got an Error while installing the postgresql on Ubuntu 22

问题

我在我的Ubuntu 22上安装了新的postgresql-12并设置了路径,但当我想要了解postgrsql的状态时,它给了我这个错误。

有谁能帮我解决这个问题?
我在安装PostgreSQL时遇到了错误,我使用的是Ubuntu 22。

谢谢你。

英文:

I have installed the new postgresql-12 on my ubuntu 22 and set the path but when I want to know the postgrsql status it is giving me this Error.

Can anyone help me with that?
我在安装PostgreSQL时遇到了错误,我使用的是Ubuntu 22。

Thank you.

答案1

得分: 1

你之所以会遇到这个错误是因为 sudo 不在路径中,
在 Linux 系统中,一切皆文件,包括命令。

你可以通过执行命令 $ echo $PATH 来检查 PATH 变量的内容。
如果在输出中找不到 /usr/bin,你可以通过执行命令

export PATH=$PATH:/usr/bin

来将 /usr/bin 添加到 PATH 变量中,因为 sudo 文件位于两个位置,即 /usr/bin 或 /bin 目录中。

这是因为在 .bashrc 文件或者你使用的任何其他 shell 中缺少了某些行,你可以通过 echo $SHELL 来检查。

只需将导出行添加到你相应的 shell 配置文件中,问题就会得到永久解决。

参考 这里 在 AskUbuntu 上的回答。

英文:

You are getting this error because sudo is not in path,
Everything is a file in linux system, even commands as well.

You can check content of PATH variable by executing command $ echo $PATH
If you do not find /usr/bin in the output than you can append /usr/bin in PATH variable by executing command

export PATH=$PATH:/usr/bin

because sudo file is located in 2 places, i.e /usr/bin or /bin directories.

It's happening because of some missing line in .bashrc file or which ever shell you are using, you can check that by echo $SHELL
Just add the export line in your respective shell config file and it'll be permanent solution.

For Reference see this answer on AskUbuntu.

答案2

得分: 0

自从sudo尝试在PATH中查找/bin:usr/bin时,您可以尝试在PATH环境变量中导出这个内容。

export PATH=$PATH:/bin:/usr/bin

注意: 如果您希望将此更改永久保存,可以尝试将其添加到~/.bashrc文件的末尾,然后使用source ~/.bashrc保存更改。

英文:

Since sudo is looking is trying to locate /bin:usr/bin in PATH, you can try exporting this in the PATH environment variable.

export PATH=$PATH:/bin:/usr/bin

Note: If you want to make this change permanent, try adding it at the end of ~/.bashrc file and then saving the changes using source ~/.bashrc.

答案3

得分: 0

sudo找不到指定的路径,解决方法是修改您的~/.bashrc文件,在最后一行添加:

export PATH="/bin:/usr/bin:$PATH"

然后运行以下命令:source ~/.bashrc

英文:

sudo cannot find the especified path, to solve it just modify your ~/.bashrc file adding in the last line:

export PATH="/bin:/usr/bin:$PATH"

and after it run the command: source ~/.bashrc

答案4

得分: 0

/usr/bin 未包含在您的环境 PATH 中。

导出路径:export PATH="/usr/bin:$PATH"

退出终端并重试。

英文:

/usr/bin is not included in your environment PATH.

export PATH="/usr/bin:$PATH"

exit out the terminal and try again.

答案5

得分: 0

请确保您提供正确的 PostgreSQL bin 目录路径,不要只是复制粘贴命令 "export PATH=/usr/lib/postgresql/12/bin/:PATH"。您可以通过在 bin 目录内运行以下命令来找到 bin 目录的路径:

pwd

您还可以按照这个博客教程,它是一个逐步教程,用于从源代码安装 PostgreSQL。

英文:

Do not just copy-paste the command "export PATH=/usr/lib/postgresql/12/bin/:PATH".

Please ensure that you provide the correct path to the PostgreSQL bin directory. You can find the path of the bin directory by running the command inside the bin directory.

pwd

Also you can follow this blog tutorial which is a step-by-step tutorial for installing PostgreSQL from source.

答案6

得分: 0

错误已经告诉你问题所在。sudo 不在 PATH 中。
因此,你应该将 sudo 添加到 ~/.bashrc 中的 PATH,然后运行 source ~/.bashrc

这应该解决这个问题。

英文:

The error already tells you the problem. sudo is not in the PATH.
Hence, you should add sudo to PATH in ~/.bashrc and run source ~/.bashrc.

This should solve this issue.

答案7

得分: 0

The error in the screenshot is saying that /bin:/usr/bin is not included in the PATH environment variable. So, you need to add this directory to the PATH variable:

export PATH="/bin:/usr/bin:$PATH"
英文:

The error in the screenshot is saying that /bin:/usr/bin is not included in the PATH environment variable. So, you need to add this directory to the PATH variable:

export PATH="/bin:/usr/bin:$PATH"

答案8

得分: 0

您的系统无法定位特定文件。

在检查系统中的PostgreSQL状态之前,请运行此命令export PATH="/bin:/usr/bin:$PATH"

英文:

Your system is unable to locate a particular file.

Run this command export PATH="/bin:/usr/bin:$PATH" before checking the status of PostgreSQL in your system.

答案9

得分: -1

你之所以出现这个错误,是因为你在没有将Postgres安装为系统服务的情况下使用了systemctl。由于你是从源代码安装的,所以你需要进入Postgres目录,并运行bin/pg_ctl status -D /path/to/data_directory来确定你的Postgres实例的状态。

英文:

You get this error because you are you using systemctl when you did not install Postgres as a system service. Since you installed from source code you have to navigate into your Postgres directory and run bin/pg_ctl status -D /path/to/data_directory to ascertain the status of your Postgres instance.

答案10

得分: -1

我认为根据错误提示,你只需将 /bin:/usr/bin 路径添加到 PATH 中,可以通过运行以下命令来实现:

export PATH=$PATH:/bin:/usr/bin

这条命令的作用是将 /bin:/usr/bin 路径添加到 PATH 中。

希望对你有所帮助,让我知道它对你的情况有何影响!

英文:

I think according to the error you should just add the /bin:/usr/bin paths to the PATH as stated, you can do that by running the following command:

export PATH=$PATH:/bin:/usr/bin

What the command does, is that it adds the /bin:/usr/bin paths to PATH.

Hope that was helpful, let me know how it goes with you!.

huangapple
  • 本文由 发表于 2023年7月23日 18:30:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76747756.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定