Cannot connect from php container to mysql server (host or mysql container)

Cannot connect from php container to mysql server.

I have a problem on my development server, which is blocking me to use Docker containers
to connect to mysql servers on my host or in a mysql container. I always get the same error
(in a host and and container mysql server)

`ERROR 2026 (HY000): TLS/SSL error: self-signed certificate in certificate chain`

So my conclusion is that there is something wrong in the php Docker file.

My docker configuration used to work for months and it does not work.
I was wondering if my Docker has been corrupted so I installed Docker to an other
computer but I still get the error.

How to make a working solution on my development server so that I connect to mysql server (host or container)?

Here is my docker file as simple as possible and how I run it.

Host
Description:	Ubuntu 24.04.3 LTS
Release:	24.04
Docker version 28.4.0

Dockerfile

# build image
docker image build -t img_docker_container_mysql_connection   -f   Dockerfile .
#run
docker run  --name  docker_container_mysql_connection \
 --privileged=true  -v ${PWD/}/var/www  img_docker_container_mysql_connection

FROM php:8.2-fpm
RUN apt-get update \
 && apt-get install -y  default-mysql-client  


# 192.168.18.3 is is the internal IP of my host
CMD [ "mysql", "-h192.168.18.3" ]

I am not an expert with mysql certgicates, but I have tried with the links below, but no help…

Hi @tuulia, could you try overriding the default behavior by setting the SSL mode explicitly in your CMD or when using mysql?

FROM php:8.2-fpm
RUN apt-get update \
 && apt-get install -y default-mysql-client

CMD [ "mysql", "-h192.168.18.3", "--ssl-mode=DISABLED" ]

Or, for partial verification (if CA is trusted):

CMD [ "mysql", "-h192.168.18.3", "--ssl-mode=VERIFY_CA", "--ssl-ca=/path/to/ca.pem" ]

Note: Using --ssl-mode=DISABLED is fine for development, but not secure for production.

Here are some reference to refer:

Hope this helps!

What is the difference in this issue compared to the other that you solved 9 days ago after two of us commented?

I may be missing something, but it looks like the same issue.

1 Like