'How do I install libmysqlclient21 on debian:buster-slim based Docker image?

I have a Docker image that is based on debian:buster-slim and I am deploying my application to it which connects to a mysql database. I have installed mysql-client: apt-get install -y default-mysql-client.

My dbdriver requires the 'libmysqlclient.so.21' library which weirdly does not come with the default-mysql-client library. So I tried to install it separately using apt-get install libmysqlclient21 but I get:

Building dependency tree       
Reading state information... Done
E: Unable to locate package libmysqlclient21 

After some research, I found out that people are installing default-libmysql-dev but this did not solve my problem either.

What can I do to be able to download this package on a Docker container? Specifically, on a debian based container.



Solution 1:[1]

I managed to install it only after adding the mysql software repository:

cd /tmp && wget https://dev.mysql.com/get/mysql-apt-config_${MYSQL_VERSION}_all.deb
dpkg -i mysql-apt-config_${MYSQL_VERSION}_all.deb
apt update
apt-get install -y libmysqlclient21 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 YanaT