About Project/Issues

MySQL : Can't create test file 경고

마이트너 2024. 3. 20. 18:37

 

mysqld --skip -grant 명령어를 이용하여
MySQL 서버가 작동하기 시작할 때 발생한
Can't create test file 경고와 Failed to set datadir 오류 해결하는 방법 알아보기



➡️ 이슈 발생

C:\Windows\System32>mysqld --skip-grant
C:\Windows\System32>

 

위 명령어는 사용자 권한을 확인하는 과정을 하지 않고 MySQL 서버에 전체 권한을 가진 누구나 연결할 수 있게 해주는 명령어이다. 정상적으로 실행된다면 아래와 같이 별 반응을 보이지 않지만, 아래와 같은 문제가 발생하기도 한다. 

C:\Windows\System32>mysqld --skip-grant
2024-03-20T09:22:59.214203Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.33) starting as process 16632
2024-03-20T09:22:59.215928Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2024-03-20T09:22:59.215961Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2024-03-20T09:22:59.216055Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno: 2 - No such file or directory)
2024-03-20T09:22:59.216579Z 0 [ERROR] [MY-010119] [Server] Aborting
2024-03-20T09:22:59.216676Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.33) MySQL Community Server - GPL.

 


➡️ 원인과 해결방법

여기서 주목할만한 로그는 Can't create test file 경고와 Failed to set datadir 오류이다. 테스트 파일을 생성할 디렉터리가 존재하지 않아 발생한 문제가 아닐까 생각하여, 나는 이 중에서 Failed to set data dir 오류에 집중하였다. 

 

Can't create test file 경고
MySQL 서버가 테스트 파일을 생성할 수 없다는 경고 로그로, 파일 시스템 권한이나 설정 문제가 원인일 가능성이 높다고 한다.
Failed to set data dir 오류
MySQL 서버가 데이터 디렉터리를 설정하는 데 실패했다는 의미로, 데이터 디렉터리가 존재하지 않거나 MySQL 프로세스가 쓰기 권한이 없는 디렉터리에 대한 작업을 시도하는 경우에 발생할 수 있다고 한다. 

 

 

때문에 data 디렉터리를 MySQL Server 8.0 내부에 생성해주었더니 문제가 해결되었다. 나는 해당 방법으로 문제가 해결되었지만 만약 이 방법으로 해결되지 않았다면, 파일 시스템 권한이 제한되어 있어 테스트 파일 생성이 안 되고 있는지를 확인해보길 바란다.

C:\Windows\System32>
mysqld --skip-grant

2024-03-20T09:22:59.214203Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.33) starting as process 16632
2024-03-20T09:22:59.215928Z 0 [Warning] [MY-010091] [Server] 
Can't create test file
 C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2024-03-20T09:22:59.215961Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2024-03-20T09:22:59.216055Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno: 2 - No such file or directory)
2024-03-20T09:22:59.216579Z 0 [ERROR] [MY-010119] [Server] Aborting
2024-03-20T09:22:59.216676Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.33) MySQL Community Server - GPL.

 

 

 

만약 data 디렉터리 생성이 안 된다면? 관리자 권한으로 실행한 cmd 창에서 명령어를 통해 해보자.

728x90