정보보안아카데미

#22 (DB보안)

이야기prog 2025. 9. 1. 13:30
반응형

DB보안추구

 

DDL(Data Definition Language) - 데이터 정의어

DML(Data Manipulation Language) - 데이터 조작어

DCL(Data Control Language) - 데이터 제어어

 

CRUD: Create, Read, Update, Delete 

 

/etc/my.cnf.d/mariadb-server.cnf

 

37번 라인 원격접속 ip 지정 0.0.0.0시 모두허용

 

mariadb에서 계정 생성시 create user 'test'@'localhost' identified by '1234';는 로컬에서만 이 계정으로 접근가능

create user 'test'@'%' identified by '1234';는 외부에서 원격으로 이 계정에 접속가능 %는 mariadb에서의 와일드카드 192.168.16.% 처럼 사용가능

 

grant create, select on test2db.student to 'test2user'@'%';

 

revoke all privileges on testdb.* from 'testuser'@'localhost'l

 

show grants for testuser@localhost;

 

 

mysql 데이터베이스에 user 테이블에 user정보와 패스워드 host 정보가 담겨있다.

 

PMM: db 모니터링 솔루션

 

Docker설치가 필요

 

#Ubuntu

sudo apt update -y
sudo apt install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

#기본저장소에는 도커를 설치할 수 없기 때문에 저장소를 설치하고 ubuntu에 등록
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update

sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin
systemctl start docker

#--------------------------------------------------------- ubuntu 18 ver 다운해서 실습해봄
#docker image 다운 
#docker images (현재 docker images 확인)
#docker ps -a (도커의 모든 프로세스 확인)
#sudo docker pull ubuntu:bionic(태그 태그값 안넣어주면 제일 최근 파일 pulling)

#sudo docker run -it ubuntu:bionic bash

#root@4370aa0b50de:/# (437~ 컨테이너 id) # docker images에 뜨는 IMAGE ID랑은 다름

# sudo docker commit (container id) ubuntu:git - 도커이미지 저장

#sudo docker rm (container id) 프로세스 삭제

#sudo docker rmi(rm image) ubuntu:bionic 


#----------------------------------------------------------

sudo curl -fsSL https://www.percona.com/get/pmm | sudo /bin/bash

id :admin passwd: admin

 

 

#pmm client

wget https://repo.percona.com/apt/percona-release_latest.generic_all.deb
sudo dpkg -i percona-release_latest.generic_all.deb

sudo percona-release enable pmm3-client
sudo apt update -y

sudo apt install -y pmm-client

#sudo pmm-admin --version 설치여부 및 버전확인

#클라이언트 서버로 등록
sudo pmm-admin config --server-insecure-tls --server-url=https://admin:admin@192.168.16.73(서버 ip)


#sudo pmm-admin status - 연결 확인

# db설치 및 적용

mysql -u -p로 접속

create user 'pmm'@'localhost' identified by '1234';

grant select, process, replication client, reload on *.* 'pmm'@'localhost';
flush privileges;

exit

sudo pmm-admin add mysql --username=pmm --password=1234 --host=localhost --port=3306 --query-source=slowlog --environment=production MYSQL-Primary

#mysql 사용시 3306포트 허용

 

 

 

반응형

'정보보안아카데미' 카테고리의 다른 글

#24(보안로그 분석)  (0) 2025.09.08
#23  (0) 2025.09.04
#21  (1) 2025.08.29
#20  (3) 2025.08.26
#19  (3) 2025.08.26