본문 바로가기
Infra

Docker MySQL container failed to start because of locked privilege table Error

by GOMJ 2024. 3. 24.

간만에 사이드 프로젝트를 하던중 docker error가 발생했다. Table 권한이 lock되어 구성에 필요한 table 생성을 못해 MySQL을 시작할 수 없다는 내용이었다. 해당 원인을 찾던중 docker volume가 container에서 필요한 directory를 구성중 충돌이 나서 에러가 발생할 수 있다고 한다. 그래서 기존에 매핑을 위해 임의로 생성했던 volume "mysql-db"를 지우고 docker에게 알아서 생성하라고 권한을 주고 실행을 하였고 정상적으로 작동함을 확인 할 수 있었다.

 

2024-03-24T00:48:54.074889Z 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
2024-03-24T00:48:54.074912Z 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.
2024-03-24T00:48:54.076110Z 0 [ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

 

기존 volume을 삭제해줬다.

docker volume rm mysql-db

 

그리고 다시 실행

docker run -d --name mysqldb --network ${network} -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=${user} -e MYSQL_PASSWORD=${password} -p 3306:3306 -v mysql-db:/var/lib/mysql mysql:latest --skip-external-locking --skip-name-resolve --innodb-buffer-pool-size=1024m

 

container 접속후 정상 작동 확인

docker exec -it mysqldb /bin/sh

// mysql 접속
mysql -u ${user} -p


// 정상 작동 확인
mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| performance_schema |
+--------------------+
2 rows in set (0.00 sec)