error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory

Apparently the program was compiled against a version of MySQL downloaded from www.mysql.com; libmysqlclient.so.20 was not available in Debian.

You can download a .deb from https://dev.mysql.com/downloads/file/?id=477124 that configures your Debian(-based) system to access the www.mysql.com apt repository. You can then update the apt data:

# apt-get update

and install the correct library:

# apt-get install libmysqlclient20

Note that this will probably want to remove your Debian version of MySQL, if installed! So consider carefully what you want.

An alternative is to browse the apt repository, and download just the libmysqlclient20 .deb manually. Unpack this, e.g.:

# dpkg-deb --extract libmysqlclient20_5.7.23-1debian9_amd64.deb /tmp/libmysqlclient20

You could then copy the libmysqlclient.so.20 to somewhere that's searched for shared libraries, e.g. /usr/local/lib/ and it should work.


In case someone else is running into this problem on Ubuntu 20.04, you can just add the older repos which will contain libmysqlclient20 to your APT sources (similar to Jylia Silver's answer.

sudo tee /etc/apt/sources.list.d/xenial.list > /dev/null <<EOF
deb http://dk.archive.ubuntu.com/ubuntu/ xenial main
deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe
deb http://dk.archive.ubuntu.com/ubuntu/ xenial-updates universe
EOF
sudo apt-get update
sudo apt-get install -y libmysqlclient20

echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list
apt-get update
apt-get install libmysqlclient20

Tags:

Mysql