installing mysql client on docker php

Here's my Dockerfile:

FROM php:7.0-apache

I do docker exec -it <hash> bash from the CLI and then do mysql and get a bash: mysql: command not found error.

I do apt-get install mysql and the package can't be located. I get the same error when I try to install mysql-client and mysql-server.

If I want to install mysql in Ubuntu mysql-client does the trick.

2 Answers

You have to customize your Dockerfile to install the mysql client on your image.

You should have to add something like after the FROM :

RUN apt-get update && apt-get install -y mysql-client && rm -rf /var/lib/apt

and of course rebuild your image.

1

my docker image: debian:stable-20200720-slim

mysql-clinet didn't work for me. after adding contrib and non-free to source.list execute this command:

apt-get update && apt install mariadb-client

then client works just fine.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like