diff --git a/.vib/mysql/goss/mysql.yaml b/.vib/mysql/goss/mysql.yaml index a340a7dd6061..f4ca2ad94de8 100644 --- a/.vib/mysql/goss/mysql.yaml +++ b/.vib/mysql/goss/mysql.yaml @@ -8,4 +8,4 @@ file: /opt/bitnami/mysql/logs/mysqld.log: exists: true filetype: symlink - linked-to: /dev/stdout + linked-to: /proc/1/fd/1 diff --git a/bitnami/mysql/8.0/debian-11/Dockerfile b/bitnami/mysql/8.0/debian-11/Dockerfile index 5bcb8bc49746..20dbf6762072 100644 --- a/bitnami/mysql/8.0/debian-11/Dockerfile +++ b/bitnami/mysql/8.0/debian-11/Dockerfile @@ -3,10 +3,10 @@ FROM docker.io/bitnami/minideb:bullseye ARG TARGETARCH LABEL org.opencontainers.image.base.name="docker.io/bitnami/minideb:bullseye" \ - org.opencontainers.image.created="2023-06-12T06:48:37Z" \ + org.opencontainers.image.created="2023-06-12T17:38:15Z" \ org.opencontainers.image.description="Application packaged by VMware, Inc" \ org.opencontainers.image.licenses="Apache-2.0" \ - org.opencontainers.image.ref.name="8.0.33-debian-11-r19" \ + org.opencontainers.image.ref.name="8.0.33-debian-11-r20" \ org.opencontainers.image.title="mysql" \ org.opencontainers.image.vendor="VMware, Inc." \ org.opencontainers.image.version="8.0.33" diff --git a/bitnami/mysql/8.0/debian-11/rootfs/opt/bitnami/scripts/libmysql.sh b/bitnami/mysql/8.0/debian-11/rootfs/opt/bitnami/scripts/libmysql.sh index fe290f338235..ce88e048f2d1 100644 --- a/bitnami/mysql/8.0/debian-11/rootfs/opt/bitnami/scripts/libmysql.sh +++ b/bitnami/mysql/8.0/debian-11/rootfs/opt/bitnami/scripts/libmysql.sh @@ -158,11 +158,11 @@ max_allowed_packet=16M bind_address=${DB_DEFAULT_BIND_ADDRESS} log_error=${DB_LOGS_DIR}/mysqld.log slow_query_log=${DB_ENABLE_SLOW_QUERY} -slow_query_log_file=${DB_LOGS_DIR}/mysqld.log long_query_time=${DB_LONG_QUERY_TIME} character_set_server=${DB_DEFAULT_CHARACTER_SET} collation_server=${DB_DEFAULT_COLLATE} plugin_dir=${DB_BASE_DIR}/lib/plugin +datadir=${DB_DATA_DIR} [client] port=${DB_DEFAULT_PORT_NUMBER} diff --git a/bitnami/mysql/8.0/debian-11/rootfs/opt/bitnami/scripts/mysql/postunpack.sh b/bitnami/mysql/8.0/debian-11/rootfs/opt/bitnami/scripts/mysql/postunpack.sh index 3d1ed02290a8..2d515594b8ee 100755 --- a/bitnami/mysql/8.0/debian-11/rootfs/opt/bitnami/scripts/mysql/postunpack.sh +++ b/bitnami/mysql/8.0/debian-11/rootfs/opt/bitnami/scripts/mysql/postunpack.sh @@ -24,5 +24,5 @@ for dir in "$DB_TMP_DIR" "$DB_LOGS_DIR" "$DB_CONF_DIR" "${DB_CONF_DIR}/bitnami" chmod -R g+rwX "$dir" done -# Redirect all logging to stdout -ln -sf /dev/stdout "$DB_LOGS_DIR/mysqld.log" +# Redirect logging to PID 1's stdout file descriptor including database initialization logs +ln -sf /proc/1/fd/1 "$DB_LOGS_DIR/mysqld.log" diff --git a/bitnami/mysql/README.md b/bitnami/mysql/README.md index cf88b9383e6e..bd7bba54e5f2 100644 --- a/bitnami/mysql/README.md +++ b/bitnami/mysql/README.md @@ -524,11 +524,32 @@ You can configure the containers [logging driver](https://docs.docker.com/engine ### Slow query logs -By default MySQL doesn't enable [slow query log](https://dev.mysql.com/doc/refman/8.0/en/slow-query-log.html) to record the SQL queries that take a long time to perform. You can modify these settings using the following environment variables: +By default MySQL doesn't enable [slow query log](https://dev.mysql.com/doc/refman/en/slow-query-log.html) to record the SQL queries that take a long time to perform. You can modify these settings using the following environment variables: * `MYSQL_ENABLE_SLOW_QUERY`: Whether to enable slow query logs. Default: `0` * `MYSQL_LONG_QUERY_TIME`: How much time, in seconds, defines a slow query. Default: `10.0` +Slow queries information is logged to the `/-slow.log` file by default, and you can easily check it with the `mysqldumpslow` tool ([link to docs](https://dev.mysql.com/doc/refman/en/mysqldumpslow.html)): + +```console +$ docker run -d -e MYSQL_ENABLE_SLOW_QUERY=1 -e ALLOW_EMPTY_PASSWORD=yes --name my-mysql-container bitnami/mysql +# wait a bit for the initialization process... +$ docker exec -it my-mysql-container mysqldumpslow +Reading mysql slow query log from /bitnami/mysql/data/-slow.log +Count: 1 Time=0.01s (0s) Lock=0.00s (0s) Rows=0.0 (0), root[root]@localhost + GRANT ALL PRIVILEGES ON *.* TO 'S'@'S' WITH GRANT OPTION + +Count: 1 Time=0.01s (0s) Lock=0.00s (0s) Rows=0.0 (0), root[root]@localhost + CREATE USER 'S'@'S' + +Count: 1 Time=0.01s (0s) Lock=0.00s (0s) Rows=0.0 (0), root[root]@localhost + DELETE FROM mysql.user WHERE user not in ('S','S') + +Count: 1 Time=0.00s (0s) Lock=0.00s (0s) Rows=0.0 (0), root[root]@localhost + flush privileges +(...) +``` + ### Slow filesystems In some platforms, the filesystem used for persistence could be slow. That could cause the database to take extra time to be ready. If that's the case, you can configure the `MYSQL_INIT_SLEEP_TIME` environment variable to make the initialization script to wait extra time (in seconds) before proceeding with the configuration operations.