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

匿名 (未验证) 提交于 2019-12-03 02:56:01

问题:

I am trying to execute pg_dump on PostgreSQL 9.0.4 server running on Debian and I am getting the error below:

./pg_dump: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory  

libpq.so.5 is a link to libpq.so.5.3 as shown below

lrwxrwxrwx 1 root root     12 Jun 27 16:24 libpq.so.5 -> libpq.so.5.3 -rwxr-xr-x 1 root root 180749 Jun 21 02:43 libpq.so.5.3 

What is it that I am doing wrong?

回答1:

Try this:

1: Know the path of 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

2: Symbolic link that library in a "well known" library path like /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:

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

3: Be happy !



回答2:

In which directory are these libpq files? You can try setting environment variable LD_LIBRARY_PATH to point to this directory or make sure it's in standard place.

Also, why isn't the libpq.so.5 link shown in the "as shown below" section? Maybe you should just run ldconfig?



回答3:

I was getting the same error message on Postgres 9.5 on RHEL 6.5 which lead me to this post. But a find for the file libpq.so.5 returned nothing, which made things more confusing.

In the end the following symbolic links made it run

ln -s /opt/rh/rh-postgresql95/root/usr/lib64/libpq.so.rh-postgresql95-5  /usr/lib64/libpq.so.rh-postgresql95-5  ln -s /opt/rh/rh-postgresql95/root/usr/lib64/libpq.so.rh-postgresql95-5  /usr/lib/libpq.so.rh-postgresql95-5 

These paths are for RHEL, use find / -name libpq.so to location your installation and add it to the same destination folders /usr/lib/ and /usr/lib64/ using the orginal file name.

The root cause appears that the installation did not place this file into a shared location.



回答4:

I had exactly the same problem with the pg 9.6 install. I fixed it like this. Rather irritating that the installer doesn't factor this in.

***********post yum install & running initdb ********* Success. You can now start the database server using:

/opt/rh/rh-postgresql96/root/usr/bin/pg_ctl -D /var/opt/rh/rh-postgresql96/lib/pgsql/data -l logfile start 

-bash-4.2$ /opt/rh/rh-postgresql96/root/usr/bin/pg_ctl -D /var/opt/rh/rh-postgresql96/lib/pgsql/data -l logfile start /opt/rh/rh-postgresql96/root/usr/bin/pg_ctl: error while loading shared libraries: libpq.so.rh-postgresql96-5: cannot open shared object file: No such file or directory

-bash-4.2$ id uid=26(postgres) gid=26(postgres) groups=26(postgres) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023


-bash-4.2$ cat LibFix ln -s /opt/rh/rh-postgresql96/root/usr/lib64/libpq.so.rh-postgresql96-5 /usr/lib64/libpq.so.rh-postgresql96-5 ln -s /opt/rh/rh-postgresql96/root/usr/lib64/libpq.so.rh-postgresql96-5 /usr/lib/libpq.so.rh-postgresql96-5


[root@****lab ~]# ln -s /opt/rh/rh-postgresql96/root/usr/lib64/libpq.so.rh-postgresql96-5 /usr/lib64/libpq.so.rh-postgresql96-5 [root@****lab ~]# ln -s /opt/rh/rh-postgresql96/root/usr/lib64/libpq.so.rh-postgresql96-5 /usr/lib/libpq.so.rh-postgresql96-5

[root@****lab ~]# su - postgres Last login: Thu Apr 5 08:57:21 CEST 2018 on pts/0

-bash-4.2$ /opt/rh/rh-postgresql96/root/usr/bin/pg_ctl -D /var/opt/rh/rh-postgresql96/lib/pgsql/data -l logfile start server starting

-bash-4.2$ ps -ef | grep postgres root 12778 7883 0 09:07 pts/0 00:00:00 su - postgres postgres 12779 12778 0 09:07 pts/0 00:00:00 -bash postgres 12802 1 0 09:08 pts/0 00:00:00 /opt/rh/rh-postgresql96/root/usr/bin/postgres -D /var/opt/rh/rh-postgresql96/lib/pgsql/data postgres 12803 12802 0 09:08 ? 00:00:00 postgres: logger process postgres 12805 12802 0 09:08 ? 00:00:00 postgres: checkpointer process postgres 12806 12802 0 09:08 ? 00:00:00 postgres: writer process postgres 12807 12802 0 09:08 ? 00:00:00 postgres: wal writer process postgres 12808 12802 0 09:08 ? 00:00:00 postgres: autovacuum launcher process postgres 12809 12802 0 09:08 ? 00:00:00 postgres: stats collector process postgres 12810 12779 0 09:08 pts/0 00:00:00 ps -ef

-bash-4.2$ id uid=26(postgres) gid=26(postgres) groups=26(postgres) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 -bash-4.2$ psql psql (9.6.5)

postgres=# \conninfo You are connected to database "postgres" as user "postgres" via socket in "/var/run/postgresql" at port "5432". postgres=#



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!