Custom MySQL docker image using existing sql file - mysql

I want to create a custom MySQL docker image in https://labs.play-with-docker.com/ using existing mysql file. MySQL file looks like below.
abc.sql
create schema my-schema1;
use my-schema1;
create table table1(
id bigint primary key,
name varchar(50)
);
insert into table1 values(7009009001,'Carry');
select * from table1;
create schema my-schema2;
use my-schema2;
create table table2(
id bigint primary key,
name varchar(50)
);
insert into table1 values(4009009001,'Marry');
select * from table2;
Dockerfile
FROM mysql
COPY ./abc.sql /docker-entrypoint-initdb.d/abc.sql
I am running below commands :
docker pull mysql:latest
docker build -f Dockerfile -t custom-mysql-img .
docker run --name=mysql-con --volume custom-mysql-volume:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -d custom-mysql-img
docker exec -it mysql-con mysql -u root -p
Container gets started and asks for password. But on executing show databases; command it only displays default schemas. I need multiple schemas and tables in my .sql file, hence don't want to put schema name in Dockerfile.
Please suggest where I am wrong.
Below is the output of docker logs mysql-con :
$ docker logs mysql-con
2021-04-18 13:16:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-18 13:16:39+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-04-18 13:16:40+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-18 13:16:40+00:00 [Note] [Entrypoint]: Initializing database files
2021-04-18T13:16:40.236069Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 42
2021-04-18T13:16:40.253242Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-04-18T13:16:40.923755Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-04-18T13:16:43.583388Z 6 [Warning] [MY-010453] [Server] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2021-04-18 13:16:47+00:00 [Note] [Entrypoint]: Database files initialized
2021-04-18 13:16:47+00:00 [Note] [Entrypoint]: Starting temporary server
2021-04-18T13:16:47.959622Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23) starting as process 87
2021-04-18T13:16:48.100393Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-04-18T13:16:48.506573Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-04-18T13:16:48.753607Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2021-04-18T13:16:49.015712Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-04-18T13:16:49.018919Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-04-18T13:16:49.023237Z 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.
2021-04-18T13:16:49.082436Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL.
2021-04-18 13:16:49+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2021-04-18 13:16:55+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/abc.sql
/usr/local/bin/docker-entrypoint.sh: line 75: /docker-entrypoint-initdb.d/abc.sql: Permission denied
2021-04-18 13:17:43+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-18 13:17:43+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-04-18 13:17:43+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-18T13:17:44.067090Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23) starting as process 1
2021-04-18T13:17:44.082414Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-04-18T13:17:45.999169Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-04-18T13:17:46.234843Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2021-04-18T13:17:46.322310Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
2021-04-18T13:17:46.378281Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
2021-04-18T13:17:46.454642Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-04-18T13:17:46.455015Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-04-18T13:17:46.459673Z 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.
2021-04-18T13:17:46.491885Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.

Related

MySQL Container keep not connecting to my container

I'm starting mysql server using docker-compose here is my docker-compose.yml file:
version: "3.9"
services:
mysqldb:
image: mysql:8.0
container_name: mysqlcontainer
command: --default-authentication-plugin=mysql_native_password
restart: unless-stopped
volumes:
- ./db/init.sql:/docker-entrypoint-initdb.d/0_init.sql
- C:/Users/crisp/OneDrive/Desktop/html/database:/var/lib/mysql
ports:
- 8080:3306
expose:
- 8080
environment:
MYSQL_DATABASE: todos
MYSQL_USER: admin
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
SERVICE_TAGS: dev
SERVICE_NAME: mysqldb
networks:
- internalnet
networks:
internalnet:
driver: bridge
Now when i use the ps docker command here is what i'm getting. The status is always Restarting
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6f8053143edf mysql:8.0 "docker-entrypoint.s…" 14 seconds ago Restarting (1) 1 second ago mysqlcontainer
If i try to debug using the logs command on the container here are the logs I'm getting
2022-08-03 06:13:31+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:13:31+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:13:31+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:13:32.094297Z 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.
2022-08-03T06:13:32.108996Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:13:32.109026Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:13:32.122288Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:13:32.235605Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:13:32.929506Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:13:33.170552Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:13:33.170867Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:13:33.171051Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:13:33.172827Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:13:37+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:13:37+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:13:37+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:13:37.902864Z 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.
2022-08-03T06:13:37.916272Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:13:37.916302Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:13:37.929765Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:13:37.974966Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:13:38.676248Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:13:38.959483Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:13:38.959809Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:13:38.959870Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:13:38.961245Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:13:42+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:13:43+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:13:43+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:13:43.811176Z 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.
2022-08-03T06:13:43.826556Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:13:43.826611Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:13:43.846354Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:13:43.918855Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:13:44.772517Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:13:45.021113Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:13:45.021339Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:13:45.021415Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:13:45.023388Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:13:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:13:49+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:13:49+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:13:49.826617Z 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.
2022-08-03T06:13:49.839972Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:13:49.840130Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:13:49.854179Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:13:49.907502Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:13:50.701530Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:13:50.932839Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:13:50.933362Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:13:50.933448Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:13:50.934985Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:13:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:13:55+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:13:55+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:13:55.672533Z 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.
2022-08-03T06:13:55.686526Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:13:55.686557Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:13:55.700405Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:13:55.796139Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:13:56.593853Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:13:56.867322Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:13:56.867705Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:13:56.867752Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:13:56.869591Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:14:00+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:14:01+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:14:01+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:14:01.815025Z 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.
2022-08-03T06:14:01.827254Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:14:01.827284Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:14:01.838250Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:14:01.929735Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:14:02.836305Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:14:03.051822Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:14:03.052113Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:14:03.052150Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:14:03.053717Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:14:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:14:09+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:14:09+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:14:09.708213Z 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.
2022-08-03T06:14:09.718157Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:14:09.718187Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:14:09.728521Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:14:09.785854Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:14:10.556984Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:14:10.847891Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:14:10.848129Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:14:10.848165Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:14:10.849647Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:14:19+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:14:20+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:14:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:14:20.807168Z 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.
2022-08-03T06:14:20.819200Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:14:20.819231Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:14:20.829042Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:14:20.904475Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:14:21.745379Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:14:22.019620Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:14:22.020038Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:14:22.020116Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:14:22.021569Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:14:37+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:14:37+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:14:37+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:14:38.336495Z 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.
2022-08-03T06:14:38.346879Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:14:38.346910Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:14:38.355982Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:14:38.401038Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:14:39.439981Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:14:39.688466Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:14:39.688836Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:14:39.688881Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:14:39.690256Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:15:07+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:15:08+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:15:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:15:08.812491Z 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.
2022-08-03T06:15:08.824051Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:15:08.824083Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:15:08.835330Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:15:08.884074Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:15:09.598467Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:15:09.842765Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:15:09.843038Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:15:09.843109Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:15:09.844406Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:16:04+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:16:04+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:16:04+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:16:05.411826Z 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.
2022-08-03T06:16:05.422864Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:16:05.422895Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:16:05.437596Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:16:05.486536Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:16:06.235782Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:16:06.504590Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:16:06.504893Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:16:06.504965Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:16:06.506629Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:17:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:17:09+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:17:09+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:17:09.710388Z 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.
2022-08-03T06:17:09.725995Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:17:09.726036Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:17:09.738785Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:17:09.836029Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:17:10.640444Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:17:10.933443Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:17:10.933749Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:17:10.933812Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:17:10.935379Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:18:13+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:18:13+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:18:13+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:18:14.339873Z 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.
2022-08-03T06:18:14.355514Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:18:14.355556Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:18:14.367405Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:18:14.470999Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:18:15.216762Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:18:15.409546Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:18:15.409939Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:18:15.409979Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:18:15.412445Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:19:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:19:18+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:19:18+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:19:18.568091Z 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.
2022-08-03T06:19:18.582955Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:19:18.582987Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:19:18.596502Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:19:18.689140Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:19:19.579966Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:19:19.845619Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:19:19.845948Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:19:19.846001Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:19:19.847771Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:20:22+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:20:22+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:20:22+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:20:23.335838Z 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.
2022-08-03T06:20:23.346428Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:20:23.346459Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:20:23.358021Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:20:23.442383Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:20:24.334394Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:20:24.581742Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:20:24.582067Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:20:24.582145Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:20:24.583429Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-03 06:21:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-03 06:21:27+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-03 06:21:27+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2022-08-03T06:21:27.858128Z 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.
2022-08-03T06:21:27.871861Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-08-03T06:21:27.871891Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-03T06:21:27.886573Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-08-03T06:21:27.937394Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-03T06:21:28.781122Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
2022-08-03T06:21:29.056997Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2022-08-03T06:21:29.057329Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-08-03T06:21:29.057392Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-08-03T06:21:29.058769Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
I don't know if these logs makes sense, but i can see that at the last line it says Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL..
When i try to connect to this mysql server on docker, here is the error that i'm getting.
"There was an error processing your request: connect ECONNREFUSED 127.0.0.1:8080"
Probably I'm missing something small here, what maybe possibly the cause of this.
This is because the data folder was corrupt during the first installation or upgradation in the middle of the building or not properly closed.
Try this step.
Try to remove the docker image.
List all images using
docker images
Remove the MySQL image
docker rmi imagename
Update: Don't forget to remove the docker volume
Find the Volumes
docker volume ls
Remove the volume
docker volume rm volumename
Also, go to your directory C:/Users/crisp/OneDrive/Desktop/html/database and remove the folder.
For Remove unused container use
docker system prune -a
Then try docker-compose up for debugging.
If no errors, you could try docker-compose up -d.
The error in your output is:
2022-08-03T06:21:28.781122Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
Don't mount a Windows folder into the Linux container for a mysql data store:
volumes:
- ./db/init.sql:/docker-entrypoint-initdb.d/0_init.sql
- C:/Users/crisp/OneDrive/Desktop/html/database:/var/lib/mysql
Use a named volume so the file system is local to the VM running Docker
volumes:
- ./db/init.sql:/docker-entrypoint-initdb.d/0_init.sql
- todo_db:/var/lib/mysql
volumes:
todo_db: {}
When you do this the database will go back to an initial blank state. Restore the database from a backup if there was something important in there.

MySQL docker container receives SHUTDOWN command

everyone. I have noticed strange behavior during MySQL docker container startup. Basically I'm trying to run the following command
docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:8.0.29
but after that I see from the logs that container after successful startup suddenly receives SHUTDOWN command, and reinitialize database again
2022-07-25T19:33:26.423537Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.29) MySQL Community Server - GPL.
Here is all the logs:
2022-07-25 19:33:19+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1.el8 started.
2022-07-25 19:33:19+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-07-25 19:33:19+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1.el8 started.
2022-07-25 19:33:19+00:00 [Note] [Entrypoint]: Initializing database files
2022-07-25T19:33:19.770157Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.29) initializing of server in progress as process 42
2022-07-25T19:33:19.775554Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-07-25T19:33:20.037982Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-07-25T19:33:21.277581Z 6 [Warning] [MY-010453] [Server] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2022-07-25 19:33:23+00:00 [Note] [Entrypoint]: Database files initialized
2022-07-25 19:33:23+00:00 [Note] [Entrypoint]: Starting temporary server
2022-07-25T19:33:23.494658Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.29) starting as process 91
2022-07-25T19:33:23.505604Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-07-25T19:33:23.590481Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-07-25T19:33:23.778598Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-07-25T19:33:23.778621Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-07-25T19:33:23.779801Z 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.
2022-07-25T19:33:23.790924Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2022-07-25T19:33:23.790961Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.29' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL.
2022-07-25 19:33:23+00:00 [Note] [Entrypoint]: Temporary server started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2022-07-25 19:33:24+00:00 [Note] [Entrypoint]: Stopping temporary server
2022-07-25T19:33:24.911894Z 10 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.29).
2022-07-25T19:33:26.423537Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.29) MySQL Community Server - GPL.
2022-07-25 19:33:26+00:00 [Note] [Entrypoint]: Temporary server stopped
2022-07-25 19:33:26+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
2022-07-25T19:33:27.122487Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.29) starting as process 1
2022-07-25T19:33:27.128121Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-07-25T19:33:27.217345Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-07-25T19:33:27.410605Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-07-25T19:33:27.410659Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-07-25T19:33:27.412287Z 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.
2022-07-25T19:33:27.431360Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2022-07-25T19:33:27.431373Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.29' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
And after second attempt container is up and running normally. So my question is - how to identify what causes to the SHUTDOWN command?
That's a normal consequence of the way the mysql image runs its first-time initialization scripts. Note the Initializing database files message and the Temporary server started...Temporary server stopped around the first Received SHUTDOWN message.
You can see this logic in the entrypoint script itself. That script runs (using shell functions defined previously in the script, trimmed down somewhat)
# there's no database, so it needs to be initialized
if [ -z "$DATABASE_ALREADY_EXISTS" ]; then
docker_init_database_dir "$#"
mysql_note "Starting temporary server"
docker_temp_server_start "$#"
mysql_note "Temporary server started"
docker_setup_db
docker_process_init_files /docker-entrypoint-initdb.d/*
mysql_note "Stopping temporary server"
docker_temp_server_stop
mysql_note "Temporary server stopped"
fi
The mysql_note lines are visible in the container output you quote.
More specifically, the temporary server is accessible over a Unix socket within the container filesystem, but it is not accessible over the network. This gives a point where the database hasn't been set up yet, but it's still possible to run local mysql commands, for example from the initdb scripts. Once this phase has been complete, then the database restarts with its normal options.
If you're probing to see if the database is ready yet, maybe using a mysql client in a shell loop or a TCP client like the wait-for script, this means that the database won't appear "ready" until all of the initdb scripts have run.

Jhipster MySQL Docker Deletes Database

When I run my Jhipster application in docker with a MySQL database, the data will be deleted after some time.
Looking at the MySQL logs, I can see that the MySQL database recieves a SHUTDOWN command from the root user, then goes through an initialization phase.
[System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.29).
[System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.29) MySQL Community Server - GPL.
[Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1.el8 started.
[Note] [Entrypoint]: Switching to dedicated user 'mysql'
[Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
[Warning] [MY-011068] [Server] The syntax '--ssl=off' is deprecated and will be removed in a future release. Please use --tls-version=invalid instead.
[System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.29) starting as process 1
[System] [MY-013576] [InnoDB] InnoDB initialization has started.
[System] [MY-013577] [InnoDB] InnoDB initialization has ended.
[Warning] [MY-011302] [Server] Plugin mysqlx reported: 'Failed at SSL configuration: "SSL context is not usable without certificate and private key"'
[System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
[System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.29' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
When it comes back online, my JHipster app doesn't have any application data saved to the database even though I have made a docker volume for MySQL and have it attached. This includes entity data and user data, so I am unable to login.
Restarting the JHipster app will give a clean install of the database connected to the application, but doing this everytime I notice MySQL has failed is not a good long-term solution.
I'm not sure if this is an error from MySQL crashing or if JHipster is somehow clearing the database with liquibase. Any help would be appreciated.

MySql docker container permission issue

After our IT department increased the server's RAM memory MySql docker container stopped working all of the sudden.
The initial error was:
2021-10-05 07:49:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.22-1debian10 started.
2021-10-05 07:49:44+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-10-05 07:49:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.22-1debian10 started.
2021-10-05 07:49:44+00:00 [Note] [Entrypoint]: Initializing database files
2021-10-05T07:49:44.695485Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.25) initializing of server in progress as process 44
2021-10-05T07:49:44.700805Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-10-05T07:49:44.709596Z 1 [ERROR] [MY-012576] [InnoDB] Unable to create temporary file; errno: 13
2021-10-05T07:49:44.709749Z 1 [ERROR] [MY-012929] [InnoDB] InnoDB Database creation was aborted with error Generic error. You may need to delete the ibdata1 file before trying to start up again.
2021-10-05T07:49:44.710086Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2021-10-05T07:49:44.710162Z 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.
2021-10-05T07:49:44.710272Z 0 [ERROR] [MY-010119] [Server] Aborting
So I've mapped the docker /tmp directory to the host's /tmp dir using the docker-compose volumes tag, which solved this issue but now I have another issue that I cannot solve, I literally can't find anything about this issue that works.
I suspect the IT person changed something in the system that cause this issue, but I can't find what.
2021-10-05 12:32:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.22-1debian10 started.
2021-10-05 12:32:08+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-10-05 12:32:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.22-1debian10 started.
2021-10-05T12:32:08.648765Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25) starting as process 1
2021-10-05T12:32:08.656676Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-10-05T12:32:08.829920Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-10-05T12:32:08.920421Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, can't create lock file /var/run/mysqld/mysqlx.sock.lock'
2021-10-05T12:32:08.921019Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060
2021-10-05T12:32:09.027024Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-10-05T12:32:09.027478Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-10-05T12:32:09.030560Z 0 [ERROR] [MY-010273] [Server] Could not create unix socket lock file /var/run/mysqld/mysqld.sock.lock.
2021-10-05T12:32:09.030972Z 0 [ERROR] [MY-010268] [Server] Unable to setup unix socket lock file.
2021-10-05T12:32:09.031807Z 0 [ERROR] [MY-010119] [Server] Aborting
Any kind of help would be appriciated.

Can't seem to get MySQL to start in Docker Container

I'm trying to get MySQL to run in a Docker Container under Windows 10 WSL 2. I attempted to start the container with this command:
docker run -d --name mysql -v /mnt/g/DockerVolumes/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=***** -e bind-address:0.0.0 -p 3306:3306 -p 33060:33060 mysql
The /mnt/g/DockerVolumes/mysql maps to a folder on an NTFS drive and not contained in the virtual drive.
The start up is aborted because the lock privilege table doesn't exist.
Below is the complete startup log.
Where did I go wrong?
NOTE: I want to keep the MySQL data files out side of a virtual hard drive for easier management AND to not fill up the system drive.
Thanks
-marc
2020-05-31 22:43:04+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
2020-05-31 22:43:04+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-05-31 22:43:04+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
2020-05-31T22:43:04.902473Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-05-31T22:43:04.902824Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20) starting as process 1
2020-05-31T22:43:04.907865Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2020-05-31T22:43:04.945736Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-05-31T22:43:06.174472Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysqld: Table 'mysql.plugin' doesn't exist
2020-05-31T22:43:06.288074Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure.
2020-05-31T22:43:06.346697Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
2020-05-31T22:43:06.438801Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-05-31T22:43:06.490799Z 0 [Warning] [MY-000054] [Server] World-writable config file './auto.cnf' is ignored.
2020-05-31T22:43:06.491760Z 0 [Warning] [MY-010107] [Server] World-writable config file './auto.cnf' has been removed.
2020-05-31T22:43:06.492104Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 18344f03-a390-11ea-9829-0242ac110002.
2020-05-31T22:43:06.643342Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-05-31T22:43:06.677570Z 0 [Warning] [MY-010069] [Server] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
mysqld: Cannot change permissions of the file 'private_key.pem' (OS errno 1 - Operation not permitted)
2020-05-31T22:43:06.781193Z 0 [ERROR] [MY-010295] [Server] Could not set file permission for private_key.pem
2020-05-31T22:43:06.781489Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-05-31T22:43:08.628123Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20) MySQL Community Server - GPL.
2020-05-31 22:57:41+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
2020-05-31 22:57:41+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-05-31 22:57:41+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
2020-05-31T22:57:42.103154Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-05-31T22:57:42.103457Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20) starting as process 1
2020-05-31T22:57:42.107950Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2020-05-31T22:57:42.142430Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-05-31T22:57:43.422720Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysqld: Table 'mysql.plugin' doesn't exist
2020-05-31T22:57:43.537107Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure.
2020-05-31T22:57:43.579174Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
2020-05-31T22:57:43.645481Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-05-31T22:57:43.698518Z 0 [Warning] [MY-000054] [Server] World-writable config file './auto.cnf' is ignored.
2020-05-31T22:57:43.700522Z 0 [Warning] [MY-010107] [Server] World-writable config file './auto.cnf' has been removed.
2020-05-31T22:57:43.701295Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 230fcd30-a392-11ea-9633-0242ac110002.
2020-05-31T22:57:43.863312Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-05-31T22:57:43.911332Z 0 [Warning] [MY-010069] [Server] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2020-05-31T22:57:43.916234Z 0 [Warning] [MY-010284] [Server] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2020-05-31T22:57:43.918367Z 0 [Warning] [MY-010284] [Server] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2020-05-31T22:57:43.959367Z 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.
2020-05-31T22:57:43.959849Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2020-05-31T22:57:43.960109Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001146 - Table 'mysql.component' doesn't exist
2020-05-31T22:57:43.960251Z 0 [Warning] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-003543 - The mysql.component table is missing or has an incorrect definition.
2020-05-31T22:57:43.960694Z 0 [ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2020-05-31T22:57:43.960866Z 0 [ERROR] [MY-010952] [Server] The privilege system failed to initialize correctly. For complete instructions on how to upgrade MySQL to a new version please see the 'Upgrading MySQL' section from the MySQL manual.
2020-05-31T22:57:43.961186Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-05-31T22:57:45.340240Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20) MySQL Community Server - GPL.
2020-05-31 22:58:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
2020-05-31 22:58:54+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-05-31 22:58:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
2020-05-31T22:58:54.696468Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-05-31T22:58:54.696779Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20) starting as process 1
2020-05-31T22:58:54.702278Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2020-05-31T22:58:54.730454Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-05-31T22:58:56.003162Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysqld: Table 'mysql.plugin' doesn't exist
2020-05-31T22:58:56.209309Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure.
2020-05-31T22:58:56.270890Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
2020-05-31T22:58:56.330541Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-05-31T22:58:56.383656Z 0 [Warning] [MY-000054] [Server] World-writable config file './auto.cnf' is ignored.
2020-05-31T22:58:56.384744Z 0 [Warning] [MY-010107] [Server] World-writable config file './auto.cnf' has been removed.
2020-05-31T22:58:56.385289Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 4e62808d-a392-11ea-9118-0242ac110002.
2020-05-31T22:58:56.543387Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-05-31T22:58:56.581873Z 0 [Warning] [MY-010069] [Server] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2020-05-31T22:58:56.586523Z 0 [Warning] [MY-010284] [Server] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2020-05-31T22:58:56.588981Z 0 [Warning] [MY-010284] [Server] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2020-05-31T22:58:56.641897Z 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.
2020-05-31T22:58:56.642366Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2020-05-31T22:58:56.642657Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001146 - Table 'mysql.component' doesn't exist
2020-05-31T22:58:56.642800Z 0 [Warning] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-003543 - The mysql.component table is missing or has an incorrect definition.
2020-05-31T22:58:56.643205Z 0 [ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2020-05-31T22:58:56.643377Z 0 [ERROR] [MY-010952] [Server] The privilege system failed to initialize correctly. For complete instructions on how to upgrade MySQL to a new version please see the 'Upgrading MySQL' section from the MySQL manual.
2020-05-31T22:58:56.643668Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-05-31T22:58:57.917989Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20) MySQL Community Server - GPL.
I resolved this by not mapping the storage to a windows volume.
Similar problem here - using Laradock Docker setup for my Laravel project on Windows Home WSL2 and the error Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist stopped MySQL container from working - the problem was with the DATA_PATH_HOST setup:
# docker/docker-compose.yml
### MySQL ################################################
mysql:
build:
context: ./mysql
args:
- MYSQL_VERSION=${MYSQL_VERSION}
environment:
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- TZ=${WORKSPACE_TIMEZONE}
volumes:
- ${DATA_PATH_HOST}/mysql:/var/lib/mysql
# docker/.env
# Choose storage path on your machine. For all storage systems
DATA_PATH_HOST=~/.projectname/data
The problem was that the magic linux home dir character ~ wasn't interpreted as the home directory but literarily - creating the data-dir for MySQL in inaccessible place and its preventing proper init - the solution is simple - just rename the data-dir to something else like:
# docker/.env
# Choose storage path on your machine. For all storage systems
DATA_PATH_HOST=/home/picard/.projectname/data
...but finding it took me half a day :(
Hopefully this will help someone to save some time :)