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

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

问题描述:

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

I'm trying to get postgres server status with:

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

但是出现以下错误:

/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

我添加了:

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/"

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

谢谢。

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

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:

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

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