1. 아래와 같이 docker container 에서 mysql 을 실행하기 위한 명령어를 입력합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ docker run -d -p 3316:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=true --name mysql mysql:5.7
Unable to find image 'mysql:5.7' locally
5.7: Pulling from library/mysql
85b1f47fba49: Pull complete
5671503d4f93: Pull complete
3b43b3b913cb: Pull complete
4fbb803665d0: Pull complete
05808866e6f9: Pull complete
1d8c65d48cfa: Pull complete
e189e187b2b5: Pull complete
02d3e6011ee8: Pull complete
d43b32d5ce04: Pull complete
2a809168ab45: Pull complete
Digest: sha256:eb9a3bca021ee178b5a69a2443462d156ff5b3d3f739c516b62d9d902ba49132
Status: Downloaded newer image for mysql:5.7
ae42dd88532a5c7a9fa235171c73ec2e1a95212db986fbd2fb22847716584035
 
cs

* MYSQL_ALLOW_EMPTY_PASSWORD 설정값은 비밀번호 없이 root 계정을 만들기 위해 사용합니다.

* local host 의 포트 3316과 docker container 의 포트 3306이 mapping 되어 있음을 확인할 수 있습니다.



2. 위의 설정을 토대로 docker mysql container 에 접속을 시도해보겠습니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ mysql -u root -p --port 3316 --host 192.168.11.31
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.20 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
 
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>
 
cs

* -u root : 접속하기 위한 계정을 입력합니다. 여기서 접속하기 위한 계정은 root 가 됩니다.

* --port 3316 : 포트를 입력합니다. local host 의 포트를 3316으로 설정했기 때문에 3316으로 접근합니다.

* --host 192.168.11.31 : host ip address 를 입력합니다.



3. 설치 및 접속 후 확인

1
2
3
4
5
6
7
8
9
10
11
mysql> show databases;
+--------------------+
 Database           |
+--------------------+
 information_schema |
 mysql              |
 performance_schema |
 sys                |
+--------------------+
5 rows in set (0.00 sec)
 
cs



'Tools > Docker' 카테고리의 다른 글

docker tomcat 8.5 설치 및 war 적재 후 실행  (0) 2017.11.07
docker container 재생 및 실행  (0) 2017.11.02
docker 실행 및 옵션  (0) 2017.11.02
docker 접속  (0) 2017.11.02
Docker Toolbox 설치  (0) 2017.10.31

+ Recent posts