1) MariaDB 10 설치.
MariaDB 공식 홈페이지에서 리포지토리 정보 취득
URL: https://downloads.mariadb.org/mariadb/repositories/ => 시키는 대로 설치
1. Choose a Distro -> CentOS
2. Choose a Release -> CentOS 7 (64-bit)
3. Choose a Version -> 10.3 [Stable]
rpm -qa Maria*
MariaDB-compat-10.3.10-1.el7.centos.x86_64
MariaDB-common-10.3.10-1.el7.centos.x86_64
MariaDB-client-10.3.10-1.el7.centos.x86_64
MariaDB-server-10.3.10-1.el7.centos.x86_64
2) MariaDB 설정
# vi /etc/my.cnf.d/server.cnf
[mysqld]
character-set-server = utf8
# systemctl start mariadb
# systemctl enable mariadb
# mysql_secure_installation => root 암호설정 됨.
# systemctl status mariadb
3) 유저 생성 및 IP 허용
https://dev.mysql.com/doc/refman/5.7/en/adding-users.html
create user 'service'@'%' identified by "password";
GRANT ALL PRIVILEGES ON *.* TO 'service'@'%';
GRANT ALL PRIVILEGES ON *.* TO 'service'@'localhost' identified by "암호";
모든 IP 허용
INSERT INTO mysql.user (host,user,password) VALUES ('%','root',password('패스워드'));
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
FLUSH PRIVILEGES;
IP 대역 허용 ( 예: 111.222.xxx.xxx )
다음과 같이 설정하면 111.222로 시작하는 모든 IP가 허용된다.
# INSERT INTO mysql.user (host,user,password) VALUES ('111.222.%','root',password('패스워드'));
# GRANT ALL PRIVILEGES ON *.* TO 'root'@'111.222.%';
# FLUSH PRIVILEGES;
# 특정 IP 1개 허용 ( 예: 111.222.33.44 )
# INSERT INTO mysql.user (host,user,password) VALUES ('111.222.33.44','root',password('패스워드'));
# GRANT ALL PRIVILEGES ON *.* TO 'root'@'111.222.33.44';
# FLUSH PRIVILEGES;
# 모든 IP를 허용한 경우 다음과 같이 원래 상태로 복구할 수 있다.
# DELETE FROM mysql.user WHERE Host='%' AND User='root';
# FLUSH PRIVILEGES;
CREATE USER 'root'@'192.168.11.%' IDENTIFIED BY "password";
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.11.%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
4) 방화벽 풀기
firewall-cmd --permanent --zone=trusted --add-source=192.168.11.1/24
firewall-cmd --permanent --zone=trusted --add-port=3306/tcp
firewall-cmd --reload