programing

mysql 포트를 표시하는 방법

luckcodes 2022. 10. 29. 15:45

mysql 포트를 표시하는 방법

3310원격에서 MySQL 」. 은 다음과 같습니다.지금까지의 설정은 다음과 같습니다.

  database:
    container_name: sfapi_db
    restart: always
    ports:
      - 3310:3306
    build:
      context: ./docker/database
    environment:
      - MYSQL_DATABASE=${DB_NAME}
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${DB_PWD}
      - MYSQL_ROOT_PASSWORD=${DB_PWD_ROOT}
    volumes:
      - dbdata:/var/lib/mysql
      - type: bind
        source: ./docker/database/my.cnf
        target: /etc/mysql/my.cnf

도커 파일입니다.

FROM mariadb:latest

CMD ["mysqld"]

EXPOSE 3310

my.cnf:

[client-server]
# Port or socket location where to connect
port = 3310
socket = /run/mysqld/mysqld.sock

# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/

가 뛰었을 때docker-compose up --build -d컨테이너 리스트에 액세스 할 수 있습니다.

여기에 이미지 설명 입력

, 포토도, 포토를 「포토」를 사용해 했습니다.sudo ufw allow 3310또한 포트 3306은 다른 컨테이너에서 사용하기 때문에 사용할 수 없습니다.3310년

어떤 이유에서인지 그곳에 가서 포트 3310이 열려 있는지 확인하면 항상 닫혀 있습니다.

어떻게 하면 고칠 수 있을까요?

경우,my.cnf을 사용하다는 음음음 then then then then then then then then then then then then then로 해야 .3306

[client-server]
# Port or socket location where to connect
port = 3306
socket = /run/mysqld/mysqld.sock

컨테이너의 컨텍스트에서는 이것이 mysql을 표시하는 포트이기 때문입니다.

아마 요?그러면 당신이 죠?3306는 ""를 했습니다"3310 servermysql의 .3306번

언급URL : https://stackoverflow.com/questions/71099929/how-to-expose-mysql-port