본문 바로가기

리눅스

docker로 mysql 컨테이너 실행하기

반응형

docker로 mysql 컨테이너 실행하기

mysql 컨테이너 실행

docker run --name mysql -e MYSQL_ROOT_PASSWORD='P@ssw0rd1!' -p 3306:3306 -d mysql:5.7

mysql 컨테이너 확인

docker ps
$ docker ps 
CONTAINER ID   IMAGE       COMMAND                  CREATED          STATUS          PORTS                               NAMES
9a8a0084b152   mysql:5.7   "docker-entrypoint.s…"   30 minutes ago   Up 30 minutes   0.0.0.0:3306->3306/tcp, 33060/tcp   mysql

mysql 컨테이너 접속

docker exec -it mysql bash
$ docker exec -it mysql bash
bash-4.2#

mysql server에 접속

mysql -u root -p
$ mysql -u root -p                 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.40 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, 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>

mysql server 엔진 버전 정보 확인

select version();
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.40    |
+-----------+
1 row in set (0.00 sec)

mysql>

 

728x90
반응형