I am running mysql container on ec2 instance(ubuntu). I have already mysql installed. I want to run another container for mysql version 8.0. I am running following command. I tried using manually created volume but still same error.
docker run --name mysql8 -e MYSQL_ROOT_PASSWORD=root -d -p 3307:3307 mysql:8.0
I am getting error. Logs of container.
docker logs 87
2025-04-03 05:31:06+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.41-1.el9 started.
2025-04-03 05:31:06+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-04-03 05:31:06+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.41-1.el9 started.
2025-04-03 05:31:07+00:00 [Note] [Entrypoint]: Initializing database files
2025-04-03T05:31:07.157751Z 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.
2025-04-03T05:31:07.157913Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.41) initializing of server in progress as process 79
2025-04-03T05:31:07.165529Z 0 [Warning] [MY-010001] [Server] Can't create thread to handle bootstrap (errno: 1)
2025-04-03T05:31:07.165575Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2025-04-03T05:31:07.165590Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2025-04-03T05:31:07.165603Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-04-03T05:31:07.166300Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.41) MySQL Community Server - GPL.
Works for me on latest Docker (not root-less) on latest Debian:
docker run --name mysql8 -e MYSQL_ROOT_PASSWORD=root1234 -p 3307:3306 mysql:8.0
2025-04-03 06:01:02+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.41-1.el9 started.
2025-04-03 06:01:02+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-04-03 06:01:02+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.41-1.el9 started.
2025-04-03 06:01:02+00:00 [Note] [Entrypoint]: Initializing database files
2025-04-03T06:01:02.766117Z 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.
2025-04-03T06:01:02.767195Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.41) initializing of server in progress as process 79
2025-04-03T06:01:02.781774Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-04-03T06:01:03.183387Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-04-03T06:01:04.472399Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2025-04-03 06:01:07+00:00 [Note] [Entrypoint]: Database files initialized
...
2025-04-03T06:01:13.712909Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.41' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
The internal port should be 3306 (right side), as that s the port MySQL is listening on.
Externally you can use 3307 (left side), especially if another instance is already running.
In general I am missing a bind mount or volume. With the current settings you write your database files into the container. If you upgrade to a new version, all data is lost.
You could try MariaDB, which should be MySQL compatible.
It was i the title, I just repeat it so it can be found in the content as well. How is the “already installed mysql” relevant? How did you create the volume? Was it empty or contained data from another MySQL instance?
I cannot be 100% sure, but I guess it could be that the data is incompatible with the MySQL version so it cannot load it if you mounted data from an existing MySQL instance.
Or in some cases, for example when you use the root of a block device as volume, it could contain files like `lost+found" on ext4. Than it could be interpreted as existing data which cannot be used.
I can’t exactly guide you through as I haven’t had to upgrade MySQL for a while, but with Docker you just get isolation, so you still need to follow the upgrade guide from MySQL. If it requires changing config files, or setting some parameters to migrate data, that must be done to avoid data loss. If the problem already happened, then hopefully you have a backup of the original data.
If you can still load the data in MySQL 5.7, that you just have to restart the upgrade process. Before you try to start MySQL 5.7 again, make sue you make a backup just just to be safe.