Error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or di

关于在用使用crontab计划任务使用pg_dump导出数据库的时候的报错:Error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory

遇到这个问题的情况是这样的:

1、root用户执行脚本

2、直接执行脚本正常,crontab定时执行报错

3、postgres用户通过crontab执行,同样报错

解决方案:

根据个人系统位数,创建libpq.so.5的软链接

1、找到ibpq.so.5,一般在PG_HOME/lib下

2、创建软链接(个人为64位系统)

ln -s /u01/PostgreSQL/12.11/lib/libpq.so.5 /usr/lib64/libpq.so.5

如果是32位的

ln -s /u01/PostgreSQL/12.11/lib/libpq.so.5 /usr/lib/libpq.so.5

再次执行crontab,成功~

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This error occurs when the system is unable to find the shared library file "libpq.so.7" required by the program. It usually happens when the library is missing or not properly installed. To resolve this issue, you can try the following steps: 1. Update the package manager: Run the command `sudo apt-get update` (for Ubuntu/Debian-based systems) or `sudo yum update` (for CentOS/RHEL-based systems) to update the package manager. 2. Install the PostgreSQL client library: Run the command `sudo apt-get install libpq-dev` (for Ubuntu/Debian-based systems) or `sudo yum install postgresql-devel` (for CentOS/RHEL-based systems) to install the PostgreSQL client library. 3. Verify the library path: Ensure that the library path is set correctly. You can check it by running the command `echo $LD_LIBRARY_PATH`. If it is empty or does not include the directory containing "libpq.so.7", you may need to add it manually. For example, if the library is located in "/usr/local/lib", you can add it to the library path by running: ``` export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ``` You can also add this line to your shell profile file (e.g., ~/.bashrc or ~/.bash_profile) to make it persist across sessions. 4. Rebuild/reinstall the program: If you are building the program from source, ensure that the library is included in the build configuration and rebuild it. If you are using a pre-compiled binary, try reinstalling it to ensure all dependencies are correctly resolved. By following these steps, you should be able to resolve the "libpq.so.7" shared library error.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值