MySQL Docker permanent restart

Hello all,

I have a problem similar to this one, only topical and not with Maria DB:

I have done a system update: Ubuntu 21.10. to 22.04.1 LTS.
After the first reboot, the Nextcloud was still accessible in the browser. Therefore, I exclude the update as a source of error.

Afterwards I updated Docker manually:

sudo add-apt-repository "deb [arch=amd64] Jammy stable"
sudo apt -y install docker-ce
sudo curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

And updated my containers:

cd /media/cloud/nextcloud
docker-compose pull
docker-compose stop
docker-compose rm
docker-compose up -d

Since that time the mysql containers could not start and are in a constant restart loop.

$ docker-compose ps
nextcloud "/ apac..." nextcloud running>80/tcp
nextcloud-mysql "docker-entrypoint.s..." mysql restarting
nextcloud-redis "docker-entrypoint.s..." redis running 6379/tcp
version: '3.7'


    image: nextcloud
    container_name: nextcloud
      - nextcloud
      - ""
      - ${NEXTCLOUD_ROOT}/html:/var/www/html
      - ${NEXTCLOUD_ROOT}/data:/srv/nextcloud/data
      - mysql
      - redis
      - NEXTCLOUD_DATA_DIR=/srv/nextcloud/data
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=nextcloud-mysql
      - REDIS_HOST=nextcloud-redis
    restart: unless-stopped

    image: mysql
    container_name: nextcloud-mysql
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: unless-stopped
      - ${NEXTCLOUD_ROOT}/mysql:/var/lib/mysql
      - ${NEXTCLOUD_ROOT}/mysql-log:/var/log/mysql
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - nextcloud

    image: redis
    container_name: nextcloud-redis
      - nextcloud
    restart: unless-stopped

  # coturn:
    # image: instrumentisto/coturn
    # container_name: nextcloud-coturn
    # restart: unless-stopped
    # ports:
      # - "3478:3478/tcp"
      # - "3478:3478/udp"
    # networks:
      # - nextcloud
    # command:
      # - -n
      # --log-file=stdout
      # - --min-port=49160
      # --max-port=49200
      # - --realm=${NEXTCLOUD_FQDN}
      # - --use-auth-secret
      # - --static-auth-secret=${COTURN_SECRET}

  # collabora:
    # image: collabora/code
    # container_name: nextcloud-collabora
    # restart: unless-stopped
    # networks:
      # nextcloud
    # ports:
      # - ""
    # extra_hosts:
    # environment:
      # - 'domain=${NEXTCLOUD_FQDN}'
      # - 'dictionaries=en en'
    # cap_add:
      # - MKNOD
    # tty: true

I have commented out coturn and collabora, since they are not absolutely necessary (and have never been actively used).

In the “mysql-log” folder there is no log at all, the path was created but is empty.

docker-compose logs -f
nextcloud-mysql  | 2022-08-17 09:09:45+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
nextcloud-mysql  | 2022-08-17 09:09:45+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
nextcloud-mysql  | 2022-08-17 09:09:45+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
nextcloud-mysql  | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
nextcloud-mysql  | 2022-08-17T09:09:45.363380Z 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.
nextcloud-mysql  | 2022-08-17T09:09:45.364235Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
nextcloud-mysql  | 2022-08-17T09:09:45.368116Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
nextcloud-mysql  | 2022-08-17T09:09:45.416683Z 1 [ERROR] [MY-012526] [InnoDB] Upgrade is not supported after a crash or shutdown with innodb_fast_shutdown = 2. This redo log was created with MySQL 8.0.27, and it appears logically non empty. Please follow the instructions at
nextcloud-mysql  | 2022-08-17T09:09:45.416714Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
nextcloud-mysql  | 2022-08-17T09:09:45.885466Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
nextcloud-mysql  | 2022-08-17T09:09:45.885594Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
nextcloud-mysql  | 2022-08-17T09:09:45.885624Z 0 [ERROR] [MY-010119] [Server] Aborting
nextcloud-mysql  | 2022-08-17T09:09:45.886024Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30)  MySQL Community Server - GPL.
nextcloud-mysql exited with code 1

All software is uptodate.

How do I fix this error?

— add edit:

$ occ
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection timed out in /var/www/html/lib/private/DB/Connection.php:139
Stack trace:
#0 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\DB\Connection->connect()
#1 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/html/lib/private/DB/Connection.php(261): Doctrine\DBAL\Connection->executeQuery('SELECT * FROM `...', Array, Array, NULL)
#3 /var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery('SELECT * FROM `...', Array, Array)
#4 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(281): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/html/lib/private/AppConfig.php(411): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/html/lib/private/AppConfig.php(176): OC\AppConfig->loadConfigValues()
#7 /var/www/html/lib/private/AppConfig.php(367): OC\AppConfig->getApps()
#8 /var/www/html/lib/private/legacy/OC_App.php(983): OC\AppConfig->getValues(false, 'installed_versi...')
#9 /var/www/html/lib/private/Server.php(713): OC_App::getAppVersions()
#10 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC\{closure}(Object(OC\Server))
#11 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#12 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet('OC\\Memcache\\Fac...')
#13 /var/www/html/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query('OC\\Memcache\\Fac...', false)
#14 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query('OC\\Memcache\\Fac...')
#15 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(184): OC\AppFramework\Utility\SimpleContainer->get('OC\\Memcache\\Fac...')
#16 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#17 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#18 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet('OCP\\ICacheFacto...')
#19 /var/www/html/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query('OCP\\ICacheFacto...', false)
#20 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query('OCP\\ICacheFacto...')
#21 /var/www/html/lib/private/Server.php(1105): OC\AppFramework\Utility\SimpleContainer->get('OCP\\ICacheFacto...')
#22 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC\{closure}(Object(OC\Server))
#23 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#24 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet('OCP\\Lock\\ILocki...')
#25 /var/www/html/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query('OCP\\Lock\\ILocki...', false)
#26 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query('OCP\\Lock\\ILocki...')
#27 /var/www/html/lib/private/Server.php(2082): OC\AppFramework\Utility\SimpleContainer->get('OCP\\Lock\\ILocki...')
#28 /var/www/html/lib/private/Files/View.php(122): OC\Server->getLockingProvider()
#29 /var/www/html/lib/private/Server.php(454): OC\Files\View->__construct()
#30 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC\{closure}(Object(OC\Server))
#31 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#32 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet('OC\\Files\\Node\\H...')
#33 /var/www/html/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query('OC\\Files\\Node\\H...', false)
#34 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query('OC\\Files\\Node\\H...')
#35 /var/www/html/lib/private/Server.php(1445): OC\AppFramework\Utility\SimpleContainer->get('OC\\Files\\Node\\H...')
#36 /var/www/html/lib/base.php(602): OC\Server->boot()
#37 /var/www/html/lib/base.php(1104): OC::init()
#38 /var/www/html/console.php(48): require_once('/var/www/html/l...')
#39 /var/www/html/occ(11): require_once('/var/www/html/c...')
#40 {main}

Most likely the problem is here:

this sequence of commands is downloading :latest docker images for respective software which is e.g. mysql 8 as of now. The problem with such approach is you might have performed unintended major release upgrade (and didn’t follow required upgrade steps) which caused another issues.

I would recommend to use defined version tags to keep (major) upgrades at your control. See What's Wrong With The Docker :latest Tag? · for details…

In you case the error

shows update is needed but can’t be performed for some reason. this is why mysql doesn’t start… please proceed with steps mysql recommends you…

1 Like

That’s correct, that’s what you should do. However, in the vast majority of instructions this is not taken into account.
But the commands themselves do not trigger :latest if you specify the version in the compose.yml!?

What upgrade? Before version 8.0.15 was installed, now version 8.0.30 … never version 5.

I tried further: created a completely new empty folder, with the same yml-config file and started it only via “docker-compose up -d”. It comes exactly the same errors. After all, the database is completely empty, new and doesn’t need an upgrade… the error message comes anyway.
Also the other errors are exactly the same.

you have a problem with your database container. please follow the instructions provided…

If a new instance shows same issues most likely something is wrong there e.g. still pointing to a volume with the previously used database files… I would recommend you focus on mysql container (maybe seek help in mysql forum) and once you get it running continue with the rest…

I only loaded the MySQL container, started it and executed a few scripts for MySQL (read in/out, Kodi database, etc.) … everything works without problems. Not a single error with the database.

Another question: Have you read the instructions yourself?
All instructions are based on logging into the DB mysql -u root -p. Since the container restarts itself all the time, this is of course not possible. Or!?

And the other point remains: I never used MySQL version 5 (here)! The very first version used here (and the only one) was MySQL 8.0.15.
I have already fetched this version as a Docker container, but it comes a similar error in addition that no downgrade is possible.
Therefore I don’t really know what to do with the “MySQL 5->8 instructions”. This seems to be a bug from my point of view.

no, why should I do? I don’t use mysql, I don’t have any way to verify if this helps… In my eyes if the application points you some instructions this is best way to start but maybe not the final destination

I’m really confused with this statement - how do you have Kodi database within new empty container (not speaking about the fact it’s not recommended and there is no reason to share database instance in docker).

But the situation remain the same - there is a problem with you mysql container and you should reach out to mysql community - who likely can help you better with your issue.

As written: only for testing! :joy:
And with an empty database test it is very difficult … so I quickly wrote many different data into this formerly empty database.

It’s a pity when you give “help” where you don’t know yourself and let the seeker waste time with it, because he is in good hope that the helper already knows what he’s doing …

No offense, but thanks for your time!

I’m sorry this is exact what I feel.

You expect professional support who solves all your problems fast… This is not what you get in this forum - this is free support so you can learn and grow. You didn’t accept and follow any advice I provided… not even the very first hint to search help within mysql community… I’m IT professional and earn 200$/h - send me the money and give me access to your system and I’ll fix your issue within hour or two… otherwise please stay polite and accept (or not) my support…

Thank you very much Willi for your incredibly great help. Thanks for everything that has solved all my problems completely. Many greetings to Switzerland and have a nice weekend.