Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install mysql client in docker image

Tags:

php

docker

mysql

I am trying to build a docker image for php, which can handle database dumping in my mysql container. The problem is that it seems to install the mariadb version instead of the mysql version of the client. This gives me an error mysqldump: unknown variable 'set-gtid-purged=OFF'

The script that does the dumping is not one I can change, as it is part of the laravel core. It detects the server sql version to see if it should add that command or not. So I really need to have the right client version on my php image/container.

This is my Dockerfile

FROM library/php:7.4-fpm

RUN apt-get update \
    && apt-get install -y default-mysql-client
like image 644
Sinnbeck Avatar asked Dec 30 '25 17:12

Sinnbeck


1 Answers

I managed to find a solution. I decided to read through how the official mysql image is built, and implement the same solution here.

https://hub.docker.com/layers/mysql/library/mysql/latest/images/sha256-b589f11ab39a852fd13090aeb56314978c73a16d615e28ec148306889b67889f?context=explore

So adding in this, installed the needed client and everything works.

RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 8C718D3B5072E1F5

RUN echo "deb http://repo.mysql.com/apt/debian/ buster mysql-8.0" > /etc/apt/sources.list.d/mysql.list

RUN apt-get update \
    && apt-get install -y mysql-community-client
like image 185
Sinnbeck Avatar answered Jan 02 '26 06:01

Sinnbeck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!