Docker - Maria DB 실행 및 설정
2023. 12. 2. 23:11ㆍ리눅스 실제 사용 팁/Docker
$ docker run -itd mariadb
---
(실행결과)
mariadb 이미지가 설치되어 있지 않아서 스스로 내려 받는다.
Unable to find image 'mariadb:latest' locally
latest: Pulling from library/mariadb
cbe3537751ce: Pull complete
5bfcd11f8751: Pull complete
ed018e89b8db: Pull complete
3e4cf40a46f9: Pull complete
938b1b815dca: Pull complete
07e09e75520d: Pull complete
82012f0ef36f: Pull complete
6430910462f4: Pull complete
Digest: sha256:c006c05608604cf21c9f5b13af3ba7d6ccb3df5bc042c3fe294e0b6d34689b55
Status: Downloaded newer image for mariadb:latest
65855dfef016eb3213ccb1189ac2a113510cca52d6748189ece3aa3ecf4d7d6f
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mariadb latest f8c340abd40f 11 hours ago 404MB
$ docker run -p 3306:3306 --name mariadb -e MARIADB_ROOT_PASSWORD=1234 -d mariadb
---
호스트/도커 각각 3306 포트 열기
데몬모드로 'mariadb' 이미지를 컨테이너로 올림
-e : 환경변수를 설정한다
MARIADB_ROOT_PASSWORD=1234
---
$ docker exec -it mariadb /bin/bash
---
앞서 데몬모드로 실행 중인 mariadb (로 명명)에 접속하기
---
(실행결과 : 접속성공)
root@7bfc43d2b5d6:/#
root@7bfc43d2b5d6:/# mariadb --version
---
(실행결과)
mariadb from 11.2.2-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using EditLine wrapper
root@7bfc43d2b5d6:/# mariadb -u root -p
Enter password: 1234 (앞에서 지정한 패스워드를 입력)
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 11.2.2-MariaDB-1:11.2.2+maria~ubu2204 mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.001 sec)
MariaDB [(none)]>
MariaDB [(none)]>
MariaDB [(none)]> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]>
MariaDB [mysql]> CREATE USER 'user'@'%' IDENTIFIED BY '1234567';
Query OK, 0 rows affected (0.003 sec)
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'user'@'%';
Query OK, 0 rows affected (0.003 sec)
MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
MariaDB [mysql]>
참고한 문서 :
'리눅스 실제 사용 팁 > Docker' 카테고리의 다른 글
Podman 윈도 버전 설치 및 초기화 (2) | 2024.10.14 |
---|---|
Podman - 도커 호환 컨테이너 엔진 (0) | 2024.10.14 |
Docker : Oracle Database (0) | 2023.08.08 |
Dockerfile (0) | 2023.08.01 |
Docker Compose (번역) (0) | 2023.05.06 |