2

When I am running my app to connect to PostgreSQL, it tell me libpq.so.5 is not found. What I am wonder what is libpq.so.5? how to make libpq.so.5 avaliable? What I am doing right now is to install postgresql using this commnad:

sudo apt-get install postgresql -y

but this has a problem that I did not want to use postgresql database, I only want to make libpq.so.5 avaliable, the posgresql takes too much space(>100MB). any other better way to make libpq.so.5 avaliable? I am now using Debian bullseye with the docker base image.

1 Answer 1

3

On Debian, libpq.so.5 (which is the shared library for postgresql client programs) is in the libpq5 package, so to install it, run:

sudo apt-get install libpq5

From the package description:

$ apt-cache show libpq5
Package: libpq5
Source: postgresql-13
Version: 13.4-3
Installed-Size: 779
Maintainer: Debian PostgreSQL Maintainers <[email protected]>
Architecture: amd64
Depends: libc6 (>= 2.25), libgssapi-krb5-2 (>= 1.17), libldap-2.4-2 (>= 2.4.7),
         libssl1.1 (>= 1.1.0)
Description-en: PostgreSQL C client library
 libpq is a C library that enables user programs to communicate with
 the PostgreSQL database server.  The server can be on another machine
 and accessed through TCP/IP.  This version of libpq is compatible
 with servers from PostgreSQL 8.2 or later.
 .
 This package contains the run-time library, needed by packages using
 libpq.
 .
 PostgreSQL is an object-relational SQL database management system.

BTW, you can use the apt-file command (which is in the apt-file package) to find which package a filename (or partial filename) belongs to. e.g.

$ apt-file search libpq.so.5
libpq5: /usr/lib/x86_64-linux-gnu/libpq.so.5
libpq5: /usr/lib/x86_64-linux-gnu/libpq.so.5.12
1
  • BTW, if you want to install only the psql command (and all of its dependencies, like libpq) then install the postgresql-client package instead of the postgresql package. Note that both of these packages just depend on specific versions of the packages (like postgresql-client-13 or postgresql-13), to make it easier to upgrade from one version of pg to another.
    – cas
    Commented Sep 13, 2021 at 4:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .