주니어 기초 코딩공부/Database 기초

Error Code: 2013. Lost connection to MySQL server during query

jju_developer 2023. 10. 10. 14:32
728x90

mysql 쿼리문 오류 문제 해결

 

쿼리문을 때릴때 마다 자꾸 타임아웃됨..

 

TCP 연결을 맺는 과정(3-way handshake)에서, connect_timeout 동안에도연결 패킷이 들어오지 않으면 연결이 실패(취소가 아님)되고,bad handshake 로 응답.

 

슬슬 열받기 전에 고쳐보자..

 

wait_timeout 을 따로 튜닝

jju...



1. Global 설정
mysql> set global interactive_timeout=10;
mysql> set global wait_timeout=10;

2. Session 설정
mysql> set interactive_timeout=10;
mysql> set wait_timeout=10;

 

※ 단, 위와 같은 방법은 MySQL 재시작 시 초기 값으로 돌아감 주의!


MySQL 시작 할때

자동으로 설정할 경우 아래와 같이 my.cnf에 설정해야함...

 

[mysqld]
interactive_timeout=10
wait_timeout=10

728x90