sprintcube / docker-compose-lamp

A basic LAMP stack environment built using Docker Compose.
MIT License
2.68k stars 1.42k forks source link

[BUG] MySQL crashes after an update = 8.4 #277

Open kjarrio opened 6 months ago

kjarrio commented 6 months ago

Describe the bug

Which Branch / PHP Version are you using ?

Steps to reproduce

Expected behavior

Error message

test-mysql8      | 2024-05-12T16:59:48.716026Z 0 [ERROR] [MY-000067] [Server] unknown variable 'default-authentication-plugin=mysql_native_password'.
test-mysql8      | 2024-05-12T16:59:48.717540Z 0 [ERROR] [MY-010119] [Server] Aborting
test-mysql8      | 2024-05-12T16:59:50.739542Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.4.0)  MySQL Community Server - GPL.
test-mysql8      | 2024-05-12T16:59:50.739616Z 0 [System] [MY-015016] [Server] MySQL Server - end.
test-mysql8 exited with code 0

This just repeats until I kill the container

Desktop (please complete the following information):

Additional context

lahirumd commented 5 months ago

I applied the fix mentioned. It resolved the authentication error. But it produces the following error and mysql keeps restarting until the container is killed.

Error message

lampdocker-mysql8      | 2024-05-14 07:31:48+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
lampdocker-mysql8      | 2024-05-14 07:31:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
lampdocker-mysql8      | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
lampdocker-mysql8      | 2024-05-14T07:31:48.855737Z 0 [System] [MY-015015] [Server] MySQL Server - start.
lampdocker-mysql8      | 2024-05-14T07:31:49.032523Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.4.0) starting as process 1
lampdocker-mysql8      | 2024-05-14T07:31:49.035380Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
lampdocker-mysql8      | 2024-05-14T07:31:49.044926Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
lampdocker-mysql8      | 2024-05-14T07:31:49.846622Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
lampdocker-mysql8      | mysqld: Table 'mysql.plugin' doesn't exist
lampdocker-mysql8      | 2024-05-14T07:31:50.007054Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure.
lampdocker-mysql8      | 2024-05-14T07:31:50.007220Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007324Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007418Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007553Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007637Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007714Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007785Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.073484Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
lampdocker-mysql8      | 2024-05-14T07:31:50.170426Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
lampdocker-mysql8      | 2024-05-14T07:31:50.187316Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
lampdocker-mysql8      | 2024-05-14T07:31:50.187825Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
lampdocker-mysql8      | 2024-05-14T07:31:50.201852Z 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.
lampdocker-mysql8      | 2024-05-14T07:31:50.205334Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.205625Z 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
lampdocker-mysql8      | 2024-05-14T07:31:50.205653Z 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.
lampdocker-mysql8      | 2024-05-14T07:31:50.206260Z 0 [ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
lampdocker-mysql8      | 2024-05-14T07:31:50.206308Z 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.
lampdocker-mysql8      | 2024-05-14T07:31:50.206376Z 0 [ERROR] [MY-010119] [Server] Aborting
lampdocker-mysql8      | 2024-05-14T07:31:51.838862Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.4.0)  MySQL Community Server - GPL.
lampdocker-mysql8      | 2024-05-14T07:31:51.838894Z 0 [System] [MY-015016] [Server] MySQL Server - end.
lampdocker-mysql8 exited with code 0 
MHostinato commented 5 months ago

I applied the fix mentioned. It resolved the authentication error. But it produces the following error and mysql keeps restarting until the container is killed.

  • OS: Windows
  • Docker Version: 26.0.0
  • PHP Version: php83
  • MySQL Version: mysql8

Error message

lampdocker-mysql8      | 2024-05-14 07:31:48+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
lampdocker-mysql8      | 2024-05-14 07:31:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
lampdocker-mysql8      | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
lampdocker-mysql8      | 2024-05-14T07:31:48.855737Z 0 [System] [MY-015015] [Server] MySQL Server - start.
lampdocker-mysql8      | 2024-05-14T07:31:49.032523Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.4.0) starting as process 1
lampdocker-mysql8      | 2024-05-14T07:31:49.035380Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
lampdocker-mysql8      | 2024-05-14T07:31:49.044926Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
lampdocker-mysql8      | 2024-05-14T07:31:49.846622Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
lampdocker-mysql8      | mysqld: Table 'mysql.plugin' doesn't exist
lampdocker-mysql8      | 2024-05-14T07:31:50.007054Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure.
lampdocker-mysql8      | 2024-05-14T07:31:50.007220Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007324Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007418Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007553Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007637Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007714Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.007785Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.073484Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
lampdocker-mysql8      | 2024-05-14T07:31:50.170426Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
lampdocker-mysql8      | 2024-05-14T07:31:50.187316Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
lampdocker-mysql8      | 2024-05-14T07:31:50.187825Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
lampdocker-mysql8      | 2024-05-14T07:31:50.201852Z 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.
lampdocker-mysql8      | 2024-05-14T07:31:50.205334Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
lampdocker-mysql8      | 2024-05-14T07:31:50.205625Z 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
lampdocker-mysql8      | 2024-05-14T07:31:50.205653Z 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.
lampdocker-mysql8      | 2024-05-14T07:31:50.206260Z 0 [ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
lampdocker-mysql8      | 2024-05-14T07:31:50.206308Z 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.
lampdocker-mysql8      | 2024-05-14T07:31:50.206376Z 0 [ERROR] [MY-010119] [Server] Aborting
lampdocker-mysql8      | 2024-05-14T07:31:51.838862Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.4.0)  MySQL Community Server - GPL.
lampdocker-mysql8      | 2024-05-14T07:31:51.838894Z 0 [System] [MY-015016] [Server] MySQL Server - end.
lampdocker-mysql8 exited with code 0 

I have the same issue

MHostinato commented 5 months ago

Hey @lahirumd , just delete the container in Docker Desktop, then empty the /data/ directory:

sudo rm -rf data/*

and then rebuild everything:

docker compose up -d --build

it worked for me.

lahirumd commented 5 months ago

Hey @lahirumd , just delete the container in Docker Desktop, then empty the /data/ directory:

sudo rm -rf data/*

and then rebuild everything:

docker compose up -d --build

it worked for me.

Awesome. You saved the day. This worked. Thanks a lot mate.

MrOffline77 commented 5 months ago

Hi Guys, sorry for the delay. I just merged the PR from @kjarrio. Let me know if you still see any issues with the db.

frivas-at-navteca commented 5 months ago

Hello, I am experiencing the same issue just now.

Environment:

❯ docker --version
Docker version 26.1.1, build 4cf5afa
❯ docker-compose --version
Docker Compose version v2.27.0-desktop.2

This is my docker-compose.yaml

services:
     db:
          image: mysql
          restart: always
          environment:
               MYSQL_ROOT_PASSWORD: password
               MYSQL_DATABASE: dbname
               MYSQL_USER: dbuser
               MYSQL_PASSWORD: dbuserpassword
          ports:
               - "13306:3306"
          volumes:
               - mysql_data:/var/lib/mysql
volumes:
     mysql_data: {}

These are the logs:

❯ docker-compose up --build
[+] Running 2/0
 ✔ Network net_default  Created                                                                                 0.0s
 ✔ Container db-1           Created                                                                                 0.1s
Attaching to db-1
db-1  | 2024-06-01 00:48:23+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
db-1  | 2024-06-01 00:48:23+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db-1  | 2024-06-01 00:48:23+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
db-1  | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
db-1  | 2024-06-01T00:48:23.963134Z 0 [System] [MY-015015] [Server] MySQL Server - start.
db-1  | 2024-06-01T00:48:24.205272Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.4.0) starting as process 1
db-1  | 2024-06-01T00:48:24.210209Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
db-1  | 2024-06-01T00:48:24.330816Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
db-1  | mysqld: Table 'mysql.plugin' doesn't exist
db-1  | 2024-06-01T00:48:24.384760Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure.
db-1  | 2024-06-01T00:48:24.384882Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
db-1  | 2024-06-01T00:48:24.385018Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
db-1  | 2024-06-01T00:48:24.385095Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
db-1  | 2024-06-01T00:48:24.385254Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
db-1  | 2024-06-01T00:48:24.385332Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
db-1  | 2024-06-01T00:48:24.385391Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
db-1  | 2024-06-01T00:48:24.385448Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
db-1  | 2024-06-01T00:48:24.410285Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
db-1  | 2024-06-01T00:48:24.474551Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
db-1  | 2024-06-01T00:48:24.479410Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
db-1  | 2024-06-01T00:48:24.479434Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
db-1  | 2024-06-01T00:48:24.481706Z 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  | 2024-06-01T00:48:24.481862Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
db-1  | 2024-06-01T00:48:24.481964Z 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
db-1  | 2024-06-01T00:48:24.481972Z 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.
db-1  | 2024-06-01T00:48:24.482560Z 0 [ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
db-1  | 2024-06-01T00:48:24.482594Z 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.
db-1  | 2024-06-01T00:48:24.482638Z 0 [ERROR] [MY-010119] [Server] Aborting
db-1  | 2024-06-01T00:48:26.033194Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.4.0)  MySQL Community Server - GPL.
db-1  | 2024-06-01T00:48:26.033231Z 0 [System] [MY-015016] [Server] MySQL Server - end.
db-1 exited with code 1

The suggested solution by @MHostinato didn't work as I don't have a data folder to remove. I will try downgrading.

Thanks everyone for the comments and suggestions!