I have a project that I have been working on and now I am experimenting with docker-compose to build it.
Before running my own custom scripts to create tables and such I thought I would just give it a go and see if it builds and I can connect to it.
I found a suitable docker-compose for mysql:
version: "3.8"
services:
mysql:
image: mysql:latest
ports:
- 3307:3307
environment:
MYSQL_ROOT_PASSWORD: SomeRootPassword1!
MYSQL_USER: someuser
MYSQL_PASSWORD: Password1!
MYSQL_DATABASE: wedding
After running docker-compose-up in gitbash I see:
mysql_1 | 2020-08-26 20:00:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
mysql_1 | 2020-08-26 20:00:14+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mysql_1 | 2020-08-26 20:00:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
mysql_1 | 2020-08-26 20:00:14+00:00 [Note] [Entrypoint]: Initializing database files
mysql_1 | 2020-08-26T20:00:14.502438Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.21) initializing of server in progress as process 43
mysql_1 | 2020-08-26T20:00:14.507639Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
mysql_1 | 2020-08-26T20:00:15.519301Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysql_1 | 2020-08-26T20:00:17.309017Z 6 [Warning] [MY-010453] [Server] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
mysql_1 | 2020-08-26 20:00:21+00:00 [Note] [Entrypoint]: Database files initialized
mysql_1 | 2020-08-26 20:00:21+00:00 [Note] [Entrypoint]: Starting temporary server
mysql_1 | 2020-08-26T20:00:22.149193Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21) starting as process 90
mysql_1 | 2020-08-26T20:00:22.170767Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
mysql_1 | 2020-08-26T20:00:22.378726Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysql_1 | 2020-08-26T20:00:22.457272Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
mysql_1 | 2020-08-26T20:00:22.549270Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
mysql_1 | 2020-08-26T20:00:22.549394Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
mysql_1 | 2020-08-26T20:00:22.553380Z 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.
mysql_1 | 2020-08-26T20:00:22.564741Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.21' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL.
mysql_1 | 2020-08-26 20:00:22+00:00 [Note] [Entrypoint]: Temporary server started.
mysql_1 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
mysql_1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
mysql_1 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
mysql_1 | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
mysql_1 | 2020-08-26 20:00:24+00:00 [Note] [Entrypoint]: Creating database wedding
mysql_1 | 2020-08-26 20:00:24+00:00 [Note] [Entrypoint]: Creating user someuser
mysql_1 | 2020-08-26 20:00:24+00:00 [Note] [Entrypoint]: Giving user someuser access to schema wedding
mysql_1 |
mysql_1 | 2020-08-26 20:00:24+00:00 [Note] [Entrypoint]: Stopping temporary server
mysql_1 | 2020-08-26T20:00:24.697408Z 14 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.21).
mysql_1 | 2020-08-26T20:00:27.792197Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.21) MySQL Community Server - GPL.
mysql_1 | 2020-08-26 20:00:28+00:00 [Note] [Entrypoint]: Temporary server stopped
mysql_1 |
mysql_1 | 2020-08-26 20:00:28+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
mysql_1 |
mysql_1 | 2020-08-26T20:00:28.931847Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21) starting as process 1
mysql_1 | 2020-08-26T20:00:28.947655Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
mysql_1 | 2020-08-26T20:00:29.162873Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysql_1 | 2020-08-26T20:00:29.250374Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
mysql_1 | 2020-08-26T20:00:29.322041Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
mysql_1 | 2020-08-26T20:00:29.322181Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
mysql_1 | 2020-08-26T20:00:29.328435Z 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.
mysql_1 | 2020-08-26T20:00:29.343021Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.21' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
The problem
Now that above is finished(Not sure if all is correct) I thought I would try and connect to it via mysql workbench but Im getting the following:
I also tried changing my binding address to :
What am I doing wrong?
In the compose file, under ports: you creating a forwarding rule from localhost:3307 to container:3307.
While you can choose any source port that is not in use on your host machine, at the other end you must hit the port on which the container is listening: in this case it would be 3306.
Your docker-compose.yml file should look like this:
version: "3.8"
services:
mysql:
image: mysql:latest
ports:
- 3307:3306
environment:
MYSQL_ROOT_PASSWORD: SomeRootPassword1!
MYSQL_USER: someuser
MYSQL_PASSWORD: Password1!
MYSQL_DATABASE: wedding
...then you should be able to connect at localhost:3307
You need to use docker internal network to bind address, instead of localhost (if you are not exposing the port), replacing 0.0.0.0 for host.docker.internal. This should do the trick.
Related
I couldn't find anything online about this.
When I start a docker container with mysql for the first time, it results very slow at startup (it takes up to 5 minutes to start). Then the next few times I start it it takes very little time and everything is normal.
The docker-compose.yml is like this:
version: "3.9"
services:
db:
image: mysql:latest
command: --default-authentication-plugin=mysql_native_password
env_file:
- .env
environment:
MYSQL_RANDOM_ROOT_PASSWORD: ${MYSQL_RANDOM_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_DATABASE_HOST: ${MYSQL_DATABASE_HOST}
MYSQL_DATABASE_PORT: ${MYSQL_DATABASE_PORT}
ports:
- 3307:${MYSQL_DATABASE_PORT}
volumes:
- mysql_data:/var/lib/mysql
volumes:
mysql_data:
Instead, here are the logs obtained in the first phase of mysql container initialization (on the left you can see the timestamp of the operations):
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:47:07+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.32-1.el8 started.
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:47:07+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:47:07+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.32-1.el8 started.
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:47:08+00:00 [Note] [Entrypoint]: Initializing database files
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:47:08.040438Z 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.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:47:08.040525Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:47:08.040543Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.32) initializing of server in progress as process 80
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:47:08.089681Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:47:25.337581Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:48:11.724097Z 6 [Warning] [MY-010453] [Server] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:50:11+00:00 [Note] [Entrypoint]: Database files initialized
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:50:11+00:00 [Note] [Entrypoint]: Starting temporary server
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:50:11.764823Z 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.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:50:11.766216Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:50:11.766238Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32) starting as process 125
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:50:12.515012Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:50:14.505933Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:50:19.710452Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:50:19.710543Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:50:19.821511Z 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.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:50:19.837273Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.32' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL.
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:50:19.837274Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:50:19+00:00 [Note] [Entrypoint]: Temporary server started.
6-testdjangomysqlnginx-db-1 | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
6-testdjangomysqlnginx-db-1 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
6-testdjangomysqlnginx-db-1 | Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
6-testdjangomysqlnginx-db-1 | Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
6-testdjangomysqlnginx-db-1 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
6-testdjangomysqlnginx-db-1 | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:50:29+00:00 [Note] [Entrypoint]: GENERATED ROOT PASSWORD: xxxxxxxxxxxxxxxxxxxxxxx
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:50:31+00:00 [Note] [Entrypoint]: Creating database blog
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:50:31+00:00 [Note] [Entrypoint]: Creating user django
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:50:32+00:00 [Note] [Entrypoint]: Giving user django access to schema blog
6-testdjangomysqlnginx-db-1 |
6-testdjangomysqlnginx-db-1 | 2023-01-28 09:50:33+00:00 [Note] [Entrypoint]: Stopping temporary server
6-testdjangomysqlnginx-db-1 | 2023-01-28T09:50:33.252374Z 13 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.32).
It seems that the operation that takes so long is [Entrypoint]: Database files initialized, is it normal?
I want to create a MySQL container purely for testing/learning purposes. If possible, I don't want to deal with extra complexities such as SSL. When I use DBeaver, connecting to
server host: localhost
port: 33060
Database: mysqldb
Username: root
Pasword: secret
Driver name: MySQL
Gives me
"null, message from server: "Host '172.21.0.1' is not allowed to connect to this MySQL server"
The logs for the Docker container is:
>docker logs 20ae6
2022-08-30 03:58:16+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-30 03:58:17+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-30 03:58:17+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-30T03:58:17.801333Z 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-30T03:58:17.803389Z 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-30T03:58:17.803424Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-30T03:58:17.812663Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-30T03:58:18.068441Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-08-30T03:58:18.405999Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-08-30T03:58:18.406051Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-08-30T03:58:18.408437Z 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-08-30T03:58:18.434789Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2022-08-30T03:58:18.434883Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.30' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
2022-08-30T04:00:19.018745Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.30).
2022-08-30T04:00:19.814521Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
2022-08-30 04:00:22+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2022-08-30 04:00:22+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-08-30 04:00: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-30T04:00:23.462649Z 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-30T04:00:23.464620Z 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-30T04:00:23.464649Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2022-08-30T04:00:23.477879Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-30T04:00:23.763140Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-08-30T04:00:24.028665Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-08-30T04:00:24.028729Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-08-30T04:00:24.031322Z 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-08-30T04:00:24.059763Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2022-08-30T04:00:24.059827Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.30' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
I start it with
docker-compose up
using
docker-compose.yml:
version: '3.7'
services:
mysql:
image: mysql:8.0
restart: always
container_name: mysqldb
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: mysqldb
MYSQL_USER: mysqluser
MYSQL_PASSWORD: mysqlpw
MYSQL_ROOT_HOST: '%'
networks:
- db
command: --default-authentication-plugin=mysql_native_password
healthcheck:
test: "mysqladmin ping -h localhost"
interval: 1s
timeout: 1s
retries: 60
volumes:
- mysql:/var/lib/mysql
ports:
- '33060:3306'
networks:
db:
driver: bridge
volumes:
mysql:
I've tried adding
MYSQL_ROOT_HOST: '%'
surrounding it both with ' and ".
and I've also tried it without this.
I also tried adding
command: --default-authentication-plugin=mysql_native_password
but it doesn't care.
I can see no sign in the log that the DBeaver test connection ever reached it. However, if I give it some other port like 33065 it gives me a connection refused. It's like it reaches some Docker/Networking/Purgatorial limbo that produces no usable output.
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.
I am trying to build two docker images for the two components of by project. One is a node application and the other is the MySQL DB. I am using a script to create the databases and fill up the tables in the DB docker image because I couldn't create stored procedures using the ORM. My configuration for it is like this:
FROM mysql:8.0.26
ADD initialization.sql /docker-entrypoint-initdb.d
ENV MYSQL_ALLOW_EMPTY_PASSWORD=thisisfine
EXPOSE 3306
When I run docker-compose up --build, the database image shuts down which causes issues with my other image. I am unable to figure out why. This is what is present in the logs:
Creating libraryly_db_1 ... done
Creating libraryly_backend_1 ... done
Attaching to libraryly_db_1, libraryly_backend_1
backend_1 | Waiting for the DB to start...
db_1 | 2021-08-15 17:10:58+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.26-1debian10 started.
db_1 | 2021-08-15 17:10:58+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1 | 2021-08-15 17:10:58+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.26-1debian10 started.
db_1 | 2021-08-15 17:10:58+00:00 [Note] [Entrypoint]: Initializing database files
db_1 | 2021-08-15T17:10:58.655968Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.26) initializing of server in progress as process 42
db_1 | 2021-08-15T17:10:58.676504Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
db_1 | 2021-08-15T17:10:59.618507Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
db_1 | 2021-08-15T17:11:01.811035Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
db_1 | 2021-08-15T17:11:01.811791Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
db_1 | 2021-08-15T17:11:02.140665Z 6 [Warning] [MY-010453] [Server] root#localhost is created with an empty password ! Please consider switching off
the --initialize-insecure option.
db_1 | 2021-08-15 17:11:07+00:00 [Note] [Entrypoint]: Database files initialized
db_1 | 2021-08-15 17:11:07+00:00 [Note] [Entrypoint]: Starting temporary server
db_1 | 2021-08-15T17:11:07.714680Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.26) starting as process 91
db_1 | 2021-08-15T17:11:07.750557Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
db_1 | 2021-08-15T17:11:08.000431Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
db_1 | 2021-08-15T17:11:08.397505Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
db_1 | 2021-08-15T17:11:08.397776Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
db_1 | 2021-08-15T17:11:08.399964Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
db_1 | 2021-08-15T17:11:08.400702Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now suppor
ted for this channel.
db_1 | 2021-08-15T17:11:08.407431Z 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.
db_1 | 2021-08-15T17:11:08.463387Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
db_1 | 2021-08-15T17:11:08.463648Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.26' socket: '/var/run/mysq
ld/mysqld.sock' port: 0 MySQL Community Server - GPL.
db_1 | 2021-08-15 17:11:08+00:00 [Note] [Entrypoint]: Temporary server started.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
backend_1 | Operation timed out
backend_1 | Starting the server...
db_1 |
db_1 | 2021-08-15 17:11:15+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/initialization.sql
backend_1 |
backend_1 | > libraryly#1.0.0 start /app
backend_1 | > node app
backend_1 |
db_1 |
db_1 |
db_1 | 2021-08-15 17:11:16+00:00 [Note] [Entrypoint]: Stopping temporary server
db_1 | 2021-08-15T17:11:16.132929Z 11 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.26).
backend_1 | Listening at: http://localhost:5000
backend_1 | ConnectionRefusedError [SequelizeConnectionRefusedError]: connect ECONNREFUSED 172.23.0.2:3306
backend_1 | at ConnectionManager.connect (/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:116:17)
backend_1 | at processTicksAndRejections (internal/process/task_queues.js:93:5)
backend_1 | at async ConnectionManager._connect (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:318:24)
backend_1 | at async /app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:250:32
backend_1 | at async ConnectionManager.getConnection (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:280:7)
backend_1 | at async /app/node_modules/sequelize/lib/sequelize.js:613:26
backend_1 | at async Sequelize.authenticate (/app/node_modules/sequelize/lib/sequelize.js:867:5) {
backend_1 | parent: Error: connect ECONNREFUSED 172.23.0.2:3306
backend_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
backend_1 | errno: -111,
backend_1 | code: 'ECONNREFUSED',
backend_1 | syscall: 'connect',
backend_1 | address: '172.23.0.2',
backend_1 | port: 3306,
backend_1 | fatal: true
I can't figure out what is causing the root user to send a shutdown request. Please help.
in this case You don't need a dockerfile if you're using docker-compose, you can configure your docker-compose file like this
version: "3.7"
services:
mysql:
image: mysql:8.0.17
container_name: localmysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: initialDatabaseName
ports:
- 3306:3306
volumes:
- /your_local/path:/var/lib/mysql
if you want to initialize your db I recommend you to use an ORM what allow you to use database migrations, or run your script from your backend
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.