Received SHUTDOWN from user root. Shutting down mysqld

My MySQL error log received this command, but I did not issue it. The result is that even though I am mounted on a data volume in my host directory, the database I previously established is missing, but the error log does not have any other information
[MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.32).

I removed your double post regarding the same topic.

If you want us to be able to help you, will need to see the compose file used to create the container, or the docker run command that was used to create the container. Furthermore, please attach a log output that allows to understand more about the situation.

I ran into the same issue. Mysql container starts normally and works some time, but then suddenly stops and after restart does not see the database. I am using two different kinds of Digital Ocean droplets:

  • 2 cpu cores + 8 Gb memory
  • 2 cpu cores + 4 Gb memory

On htop I can see mysql uses ~600 Mb memory and around 5% cpu. There is enough disk space (greater than 10 Gb) on each machine.
DB itself is nothing unusual: ~30 tables, the biggest one has up to 1 million records. DB takes 1.5 Gb space on the disk drive.

On the node with 8 Gb memory mysql could work up to 5-7 days before it crashes. On the 4 Gb node I saw it stop working overnight.

My best guess is that mysql at some point needs all the memory on the node and a bit more. Swap is turned off on DO droplets. But on the logs there is nothing about the lack of memory, it just says “Received SHUTDOWN from user root.”

Here is docker-compose.yml I am using:

services:
  wu-mysql:
    image: mysql
    container_name: wu-mysql
    ports:
      - "3306:3306"
    expose:
      - "3306"
    environment:
      - MYSQL_DATABASE=wudb
      - MYSQL_USER=dev
      - MYSQL_PASSWORD=******
      - MYSQL_ROOT_PASSWORD=*******
    volumes:
      - ./sql:/sql
      - ./data:/var/lib/mysql

Here are the logs from the container after it stops:

root@dev2:~# docker logs --tail 200 da4f3e5bf7e0
2023-10-12 22:23:30+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.1.0-1.el8 started.
2023-10-12 22:23:30+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2023-10-12 22:23:30+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.1.0-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2023-10-12T22:23:31.072993Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2023-10-12T22:23:31.473480Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-10-12T22:23:31.477112Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.1.0) starting as process 1
2023-10-12T22:23:31.494673Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-10-12T22:23:31.867158Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-10-12T22:23:32.332452Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-10-12T22:23:32.332513Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-10-12T22:23:32.338231Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2023-10-12T22:23:32.388898Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2023-10-12T22:23:32.389087Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.1.0'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
2023-10-13T05:13:49.643047Z 216 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.1.0).
2023-10-13T05:13:51.645493Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 168  user: 'dev'.
2023-10-13T05:13:51.646683Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 24  user: 'dev'.
2023-10-13T05:13:51.647066Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 169  user: 'dev'.
2023-10-13T05:13:51.647905Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 25  user: 'dev'.
2023-10-13T05:13:51.648490Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 26  user: 'dev'.
2023-10-13T05:13:51.649242Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 170  user: 'dev'.
2023-10-13T05:13:51.649751Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 27  user: 'dev'.
2023-10-13T05:13:51.650794Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 171  user: 'dev'.
2023-10-13T05:13:51.651201Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 28  user: 'dev'.
2023-10-13T05:13:51.651924Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 20  user: 'dev'.
2023-10-13T05:13:51.652369Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 172  user: 'dev'.
2023-10-13T05:13:51.653154Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 21  user: 'dev'.
2023-10-13T05:13:51.653588Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 173  user: 'dev'.
2023-10-13T05:13:51.654137Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 165  user: 'dev'.
2023-10-13T05:13:51.655129Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 22  user: 'dev'.
2023-10-13T05:13:51.655625Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 174  user: 'dev'.
2023-10-13T05:13:51.655971Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 166  user: 'dev'.
2023-10-13T05:13:51.656526Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 23  user: 'dev'.
2023-10-13T05:13:51.656867Z 0 [Warning] [MY-010909] [Server] /usr/sbin/mysqld: Forcing close of thread 167  user: 'dev'.
2023-10-13T05:13:52.904131Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.1.0)  MySQL Community Server - GPL.
2023-10-13T05:13:52.905902Z 0 [System] [MY-015016] [Server] MySQL Server - end.

Does anyone has a solution to this? Since I am experiencing the same issue at the moment!

What I noticed in my case is that I changed the credentials for my user and also for the root in the .env files (root still had the password root) but after I build the app again I was using the old volume with the old credentials. No I deleted the volume built everything again and used a mysqldump to populate the database. Hopefully this will resolve my issue!