마리아 DB 초기셋팅

ITKHJ·2022년 10월 15일
0

Database

목록 보기
1/4
post-thumbnail

마리아DB 설치
yum -y install mariadb-server mariadb

systemctl start mariadb - mariadb 시작

마리아 DB 초기 셋팅

(1) 설정
- 테이블 대소문자 무시
vi /etc/my.cnf.d/mariadb-server.cnf
[mysqld]

# 0 : 대소문자 구분, 1 : 대소문자 구분하지 안함 (소문자로 저장), 		 2 : 대소문자 구분하지 안함 (소문자로 비교)
lower_case_table_names = 1 
추가

collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

# systemctl stop mariadb
# systemctl start mariadb

# 마리아DB 접속
mysql -uroot
패스워드입력

# 적용 확인
show variables like 'lower_case_table_names';

(2) utf8
• vi /etc/my.cnf.d/client.cnf
[client]
default-character-set=utf8

• vi /etc/my.cnf.d/mysql-clients.cnf
[mysql]
default-character-set=utf8

[mysqldump]
default-character-set=utf8

sudo systemctl restart mariadb --> MariaDB 재시작

mysql -uroot 로 마리아 DB 접속 후

show variables like 'c%';로 인코딩 변경 확인

(3) 디비
- 디비 계정 생성
create user test_pos_user@localhost identified by 'test!123';
create user test_pos_user@'%' identified by 'test!123';

create user test_rnd_user@localhost identified by 'test!123';    
create user test_rnd_user@'%' identified by 'test!123';    

- 디비 생성 
create database test_pos_db ;
create database test_rnd_db ;
show databases; 

(4) 권한

- 로컬 권한
grant all privileges on test_pos_db.* to test_pos_user@localhost identified by 'pos_user!@#$%';
grant all privileges on test_rnd_db.* to test_rnd_user@localhost identified by 'rnd_user!@#$%';

- 모든 권한
grant all privileges on test_pos_db.* to test_pos_user@`%` identified by 'pos_user!@#$%' ;
grant all privileges on test_rnd_db.* to test_rnd_user@`%` identified by 'rnd_user!@#$%' ;
flush privileges; - 권한 적용

(5) 복구
mysql -uroot -p test_pos_db < /home/sql_src/test_pos_db/PAS_KCG_LICENSE.sql

(6) 마리아 DB 계정생성 및 모든 권한 부여하기

마리아 DB 접속

mysql -u root

마리아 DB 모든 사용자 계정 확인

use mysql;

select host, user from user;

특정 IP에서 허용하는 root계정 생성

create user 'root'@'192.168.0.205' identified by 'test!123';

생성된 root 계정에 모든 권한 부여하기

grant all privileges on . to 'root'@'192.168.0.57';

profile
모든 업무 지식 작성하자!

0개의 댓글