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
3
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.
If you build that image then run
docker run -it <MyImageName> bash
you can kinda explore what is going on.apt show default-mysql-client
shows the following so you are correct it is mariadb.
You can then run
apt search mysql
to find other packages you can use.I glanced through a few of them but didn’t find any that seemed like non maraidb. But you can add it to your apt repo using the following steps.
https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/
As stated by @jeff-h above, the answer has slightly changed since November 2021:
The key difference here (pun intended) is the new keyserver address.
ha.pool.sks-keyservers.net
keyserver.ubuntu.com
Edit; Added the new key from @jeff-h’s comment below.