centOS7 + MariaDB 설치 방법 & 설정

centOS7 + MariaDB 설치 방법 & 설정

아직도 고민중인데 웹통을 방문하시는 분들의 능력치를 어느 정도라 생각하고 글을 써야 할까? 여전히 답은 모르겠고…

이에 대해서 고민하게 된 이유가 아래 누군가는 알아볼만한 centos7 + Nginx + PHP8 + mariaDB 서버 설치 및 기본 설정

방문하시는 분의 능력치에 따라 위 글만 보고도 이해 할 수도 있고 아닐 수도 있을 것이란 이유에서 능력치에 대한 고민을 할수 밖에 없었다.

이 글만 가지고 성공하지 못하는 분들을 대상으로 포스팅을 하기엔 생각했던 것보다 보충해야 할 것들이 무척 많았다.

그래서 일단은 보여주기 위한 포스팅이기 보다는 정리하는 포스팅으로서 작성하려 한다.

사실 앞으로 적을 내용이라 해봤자, 잠깐만 구글링을 해봐도 이미 많다…

그럼에도 포스팅을 하는 이유는 많고 많은 자료를 토대로, 나 역시 이런 저런 시도를 해봤지만, 한번에 성공한 적이 없었기 때문이다.

나의 성공기가 누군가에게는 도움이 되겠지?

포스팅은 아래 순서대로 준비하려 한다.

목차를 봐도 알겠지만 OS 는 centOS7 을 기반으로 한다.

목차

  1. centOS7 + MariaDB 설치 방법 & 설정
  2. centOS7 + Nginx 설치 방법 & 설정
  3. centOS7 + PHP8 설치 방법 & 설정
  4. 그 밖 명령어 정리 또는 certbot 이용한 Let’s Encrypt SSL 인증서 받는 방법

이번에는 위에서 정한 순서와 같이 centOS7 + MariaDB 설치 방법 & 설정 방법에 대해서….

MariaDB 설치 순서는 아래와 같다.

  1. yum repo에 MariaDB 등록
  2. MariaDB 설치
  3. MariaDB 실행
  4. 방화벽에 등록
  5. 보안 설정
    1. 보안 설정 및 root 계정 비밀번호 변경
  6. MariaDB 재시작
  7. 부록 : 기본 인코딩 타입 변경

보충 자료를 찾다, 구글링을 해 보니 yum repo 를 이용하지 않고도 설치할 수 있는 방법이 있었다.

이와 같은 방법 https://jeongyd.tistory.com/54 이렇게 해 본 적이 없어, 앞서 말한 바와 같이 나의 성공기를 바탕으로 작성하겠다.

이제 본격적으로 centOS7 에 MariaDB 설치를 시작 해본다.

  1. yum repo 에 MariaDB 등록.

$ vi /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

위의 텍스트를 입력하고 저장 후 빠져 나온다.

2. MariaDB 설치

$ yum install -y mariadb mariadb-server

3. MariaDB 실행

$ sudo systemctl start mariadb

4. 방화벽에 등록

$ sudo systemctl enable mariadb

5. MariaDB (mysql) 보안 설정

$ mysql_secure_installation

5-1 보안 설정(비밀 번호 변경)

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we’ll need the current
password for the root user. If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): ## 처음 설정하는 경우라면 ENTER 로 넘어간다
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

You already have a root password set, so you can safely answer ‘n’.

Change the root password? [Y/n] y ## root 계정의 패스워드를 교체할것인지 물어본다
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y ## anonymous 계정을 삭제할것인지 물어봄
… Success!

Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n ## 외부에서 root 계정의 로그인을 허용할것인지 물어봄
… Success!

By default, MariaDB comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y ## test 데이터베이스를 삭제할것인지 물어봄
– Dropping test database…
… Success!
– Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y ## privileges 테이블을 재시작할 것인지 물어봄
… Success!

Cleaning up…

All done! If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

6. MariaDB 재시작

$ sudo systemctl restart mariadb

여기까지 하면 centOS7 + MariaDB 기본 설치가 됐다.

편의에 따라 heidisql 이나 phpMyAdmin 과 같은 DB 관리 툴을 이용할 수 있겠다. (아직 nginx 랑 PHP 도 설치 안 해 놓고 phpMyAdmin 을 쓰겠다고?ㅋ)

부록 MariaDB 기본 데이터 인코딩 타입을 utf8로 변경

• /etc/my.cnf.d/client.cnf

[client]
default-character-set=utf8

• /etc/my.cnf.d/mysql-clients.cnf

[mysql]
default-character-set=utf8
[mysqldump]
default-character-set=utf8

• /etc/my.cnf.d/server.cnf

[mysqld]
collation-server = utf8_unicode_ci
init-connect=’SET NAMES utf8′
character-set-server = utf8

뭔가 많이 부족해 보인다. 최초에 centOS 에 MariaDB 를 설치하겠다고 발악했던 것이 어제 같은데..

부디 이 글이 누군가에게 도움이 되길 바라며~

Author: admin

2 thoughts on “centOS7 + MariaDB 설치 방법 & 설정

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다