skip to Main Content

I’m not sure what is happening or why this is happening so hopefully someone can give me tips on how to debug or where to look.

I have 2 docker containers, 1 for phpmyadmin and another for mysql. The phpmyadmin container is linked with the mysql container. When everything is/was working, I am able to log into my database thru the phpmyadmin login page with credentials I had setup.

However, and this has happened a couple times in the past already; yesterday I can log into mysql thru phpmyadmin, today when I try to log into mysql thru phpmyadmin, I’m not able to and I got a "Cannot log in to the MySQL server. mysqli::real_connect(): (HY000/2002): No such file or directory. I don’t do anything to my host server and it happens.

Also, there doesn’t seem to be a set pattern of time either. One time I was able to log in for 3 months before this happened, another time, it was 3 wks, and yet another time it was 6 days before I couldn’t log in.

enter image description here

The funny thing is I can log into mysql via the cli after I log into the mysql docker container so mysql wasn’t broken or down:

$ docker exec -it mysql /bin/bash
root@3752a707feb7:/# mysql --u username -ppwd
...
...
Your MySQL connection id is 12489
Server version: 8.0.23 MySQL Community Server - GPL
...
...    
mysql> show databases
    -> ;
+----------------------+
| Database             |
+----------------------+
| information_schema   |
| mysql                |
...
...
+----------------------+
8 rows in set (0.03 sec)

mysql> 

When I check my host and docker, I don’t see any evidence the host or docker containers restarted.

$ w
 16:16:59 up 160 days, 22:27,  3 users,  load average: 0.02, 0.01, 0.00
...
...
$ docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS        PORTS                                NAMES
eead5d490e89   phpmyadmin     "/docker-entrypoint.…"   3 months ago    Up 3 months   0.0.0.0:8080->80/tcp                 myadmin
3752a707feb7   mysql:latest   "docker-entrypoint.s…"   18 months ago   Up 5 months   33060/tcp, 0.0.0.0:33060->3306/tcp   mysql
...
...
$ docker events --since '2022-05-01' | grep eead5d490e89
(Doesn't show any container restarts or container destroys.  I can put the log lines here if needed but it was A LOT of log lines)

The "fix" I did before was to just restart the phpmyadmin container and tell it to reconnect to mysql. I’d like to avoid doing this if possible and figure out what is making it disconnect in the first place.

What else can I check to see why from time to time the phpmyadmin docker container doesn’t allow me to log into the mysql docker container?

2

Answers


  1. I’ve had this error, I changed my port to 8080 and it worked

    Login or Signup to reply.
  2. Are you trying to initialise mysql-server with any database? I have observed that in case a heavy sql file is loaded to mysql-server, it requires time to complete the import process before it becomes accessible through remote login.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search