Search code examples
mysqldockerdebian

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

  • 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