postgresql pg_ctl:加载共享库时出错:libpq.so.5

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28526935/
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:47:31  来源:igfitidea点击:

pg_ctl: error while loading shared libraries: libpq.so.5

postgresql

提问by 0xAX

I'm trying to get postgres server status with:

我正在尝试通过以下方式获取 postgres 服务器状态:

sudo /etc/init.d/postgres status -u postgres

But getting following error:

但收到以下错误:

/home/alex/olddisk/usr/local/pgsql/bin/pg_ctl: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory

I added:

我补充说:

export LD_LIBRARY_PATH=""
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/alex/olddisk/usr/local/pgsql/lib/"

to my .bashrc, but it didn't help.

到我的.bashrc,但它没有帮助。

Thank you.

谢谢你。

回答by Rahul R

Please ensure you have 'postgresql94' package installed as well (in addition to postgresql94-server, postgresql94-lib, postgresql94-devel and whatever other PG related package you already have). These libraries get installed along with that package.

请确保您还安装了“postgresql94”包(除了 postgresql94-server、postgresql94-lib、postgresql94-devel 以及您已经拥有的任何其他 PG 相关包)。这些库与该软件包一起安装。

回答by mancini0

I ran into this error when I built postgresql from source using the --prefix flag. Building from source installs the necessary shared libs to the libs folder under the prefix directory you specified, instead of the usual place installations put shared libs. To solve the problem I just added the [prefix].libs folder to the LD_LIBRARY_PATH environment variable. For example, after building postgres using --prefix /mike/sandbox/postgres, the below command solved the issue:

当我使用 --prefix 标志从源代码构建 postgresql 时遇到了这个错误。从源代码构建会将必要的共享库安装到您指定的前缀目录下的 libs 文件夹中,而不是通常放置共享库的地方安装。为了解决这个问题,我只是将 [prefix].libs 文件夹添加到 LD_LIBRARY_PATH 环境变量中。例如,在使用 --prefix /mike/sandbox/postgres 构建 postgres 之后,下面的命令解决了这个问题:

export LD_LIBRARY_PATH=/mike/sandbox/postgres/lib:$LD_LIBRARY_PATH

导出 LD_LIBRARY_PATH=/mike/sandbox/postgres/lib:$LD_LIBRARY_PATH

回答by Yahya Yahyaoui

I think this issue is duplicated, I faced the same problem and posted a solution here.

我认为这个问题是重复的,我遇到了同样的问题并在此处发布了解决方案。

try this:

试试这个:

1: Know the path of "libpq.so.5"

1:知道“libpq.so.5”的路径

find / -name libpq.so.5

Output example: "/usr/pgsql-9.4/lib/libpq.so.5" If found nothing, check if you have already installed the suitable postgresql-libs for your postgresql version and your OS platform

输出示例:"/usr/pgsql-9.4/lib/libpq.so.5" 如果什么也没找到,请检查您是否已经安装了适合您的 postgresql 版本和操作系统平台的 postgresql-libs

2: Symbolic link that library in a "well known" library path like "/usr/lib":

2:将该库符号链接到“众所周知”的库路径中,例如“/usr/lib”:

ln -s /usr/pgsql-9.4/lib/libpq.so.5 /usr/lib/libpq.so.5

Attention: If your platform is 64 bit, you MUST also symbolic link to 64 bit libraries path:

注意:如果您的平台是 64 位,您还必须符号链接到 64 位库路径:

ln -s /usr/pgsql-9.4/lib/libpq.so.5 /usr/lib64/libpq.so.5

3: Be happy !

3:快乐!

回答by hagello

Some ideas:

一些想法:

  • Your modified ~/.bashrconly takes effect when you start a new (interactive) shell. Though catching up on that will not help you because:

  • /etc/sudoers, your configuration file of sudo, probably specifies env_reset. This means, that /etc/init.d/postgreswill not see the content of $LD_LIBRARY_PATHof your shell.

  • Insert debug statements in /etc/init.d/postgresto verify what I told you: echo "LDPATH: $LD_LIBRARY_PATH" >&2

  • Check /etc/init.d/postgres. Probably you will have to insert the third one of your exportstatements near the start of this script. Or you will have to update an existing export LD_LIBRARY_PATH=statement.

  • 您的修改~/.bashrc仅在您启动新的(交互式)shell 时生效。虽然赶上这对你没有帮助,因为:

  • /etc/sudoers,您的配置文件sudo,可能指定了env_reset. 这意味着,/etc/init.d/postgres将看不到$LD_LIBRARY_PATH您的 shell的内容。

  • 插入调试语句/etc/init.d/postgres以验证我告诉您的内容:echo "LDPATH: $LD_LIBRARY_PATH" >&2

  • 检查/etc/init.d/postgres。可能您必须在export此脚本的开头附近插入第三个语句。或者您将不得不更新现有export LD_LIBRARY_PATH=语句。

回答by Bruno

Have you installed the necessary libraries? If you are using ubuntu try:

您是否安装了必要的库?如果您使用的是 ubuntu,请尝试:

  sudo apt-get install libpq libpq-dev