본문 바로가기

인프라 & 배포

[docker] MySQL 컨테이너 포트 변경, IntelliJ database 연결 오류

mysql workbench가 3306번 포트를 사용하고 있어서

 

docker 컨테이너를 3307번 포트로 생성했다

docker run --name mysql-container -e MYSQL_ROOT_PASSWORD=root -d -p 3307:3307 mysql:8.0.33

 

 

 

IntelliJ에서 database를 연결하려는데 에러 발생 ㅜㅜ

 

 

Failed

Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.

 

 

컨테이너를 삭제했다가 다시 실행도 해보고

3306번 포트로 컨테이너를 다시 만들기도 해봤지만 계속 오류가 났다

 

 

C:\Users\uzxn>docker exec -it mysql-container bash
bash-4.4# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

mysql 접속은 문제 없이 되는데 도대체 뭐가 문제??

 

 

mysql> show global variables like 'PORT';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3306  |
+---------------+-------+
1 row in set (0.00 sec)

 

구글링 하다가 발견한 방법을 시도해봤는데

port 번호가 3306으로 되어있었다

 

 

 

 

docker desktop에서 컨테이너 > Files 탭

 

etc/my.conf 파일을 열어서 

port = 3307

를 추가하고 저장했다

 

그리고 컨테이너를 재실행 하고 다시 포트 번호를 확인해봤다

 

C:\Users\uzxn>docker restart mysql-container
mysql-container

C:\Users\uzxn>docker exec -it mysql-container bash
bash-4.4# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show global variables like 'PORT';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3307  |
+---------------+-------+
1 row in set (0.01 sec)

mysql>

 

포트 번호가 3307로 변경됐다..!!!

 

제발 연결 돼주세요

 

 

ㅜㅜㅜ 아까는 보이지 않던 데이터베이스들이 보인다

 

 

Test Connection 성공!! ㅜㅜ

 

 

ㅎㅎ 연결 완료 🤍


let textNodes = document.querySelectorAll("div.tt_article_useless_p_margin.contents_style > *:not(figure):not(pre)"); textNodes.forEach(function(a) { a.innerHTML = a.innerHTML.replace(/`(.*?)`/g, '$1'); });