티스토리 뷰

Backend/Server

CentOS8. MariaDB 설치하기

out of coding 2020. 1. 19. 11:33

Spring 기본 구조에 대해서는 알아보았고, MariaDB를 설치하여서 DB도 연결하여 보려고 합니다.

 

제가 사용한 환경은 CentOS8. MariaDB 10.4 현재는 Stable 입니다.

 

CentOS8 설치 방법은 여기

2020/01/18 - [Web/Server] - VirtualBox에 CentOS8 설치하기

 

VirtualBox에 CentOS7 설치하기

VirtualBox에 CentOS7을 설치하는 방법을 정리해볼게요. 다른 OS에 MySQL을 설치하려고 하면서 설치하는 방법을 정리하려고 합니다. 1. 새로 만들기를 누름 이름을 지정하여 주고, 머신 폴더를 지정하여 줍니다...

mrgamza.tistory.com

아주 기본 설정은 여기

2020/01/19 - [Web/Server] - CentOS8. 설치하고 기본적으로 변경 할 것. Hostname, KST변경

 

CentOS8. 설치하고 기본적으로 변경 할 것. Hostname, KST변경

설치하고 난 다음에 기본적으로 변경하여야 할 부분들에 대해서 정리해 보려고 합니다. 점점 추가되면 또 넣어 볼게요. 1. Hostname 변경 서버의 구성이 한대가 아니고 여러대여서 Master-Slave 구조로 관리 해야..

mrgamza.tistory.com

참고할 부분이 있으시면 참고 바랍니다.


MariaDB 설치

기본적으로 Linux yum repository에는 MariaDB가 등록되어 있지 않다고 합니다.

버전마다 달라서 그런거 같기는 합니다.

 

이곳에 가면 자신의 OS에 맞게 세팅하는 방법이 나와 있습니다.

https://downloads.mariadb.org/mariadb/repositories/

 

MariaDB - Setting up MariaDB Repositories - MariaDB

To generate the entries select an item from each of the boxes below. Once an item is selected in each box, your customized repository configuration will appear below. 1. Choose a Distro SLES openSUSE Arch Linux Mageia Fedora CentOS RedHat Mint Ubuntu Debia

downloads.mariadb.org

저는 CentOS. x86_64. 10.4로 선택하였습니다.

MariaDB Downloads Select

/ect/yum.repos.d/mariadb.repo 에 해당 내용을 적어주세요.

# vi /etc/yum.repos.d/mariadb.repo

파일 안의 내용

# MariaDB 10.4 CentOS repository list - created 2020-01-19 02:20 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos8-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

그리고 다음을 실행합니다.

sudo dnf install boost-program-options
sudo dnf install MariaDB-server MariaDB-client --disablerepo=AppStream 
sudo systemctl start mariadb

어엄청나게 오래 걸릴겁니다. 다운로드 속도가 빠르지도 않고. 아무튼 그렇습니다.

 

Manage MariaDB Service

# systemctl start mariadb
# systemctl stop mariadb
# systemctl status mariadb

위에서 부터 시작 / 종료 / 상태 확인 입니다.

[deploy@database ~]$ systemctl status mariadb
● mariadb.service - MariaDB 10.4.11 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Sun 2020-01-19 01:11:04 KST; 2h 14min ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 12052 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 30 (limit: 11513)
   Memory: 76.0M
   CGroup: /system.slice/mariadb.service
           └─12052 /usr/sbin/mysqld

Active: active (running) 이면 정상입니다.

 

Secure MariaDB Installation

보안 관련된 부분을 설정하는 명령을 사용합니다.

$ mysql_secure_installation

다음과 같은 부분이 나올텐데 영어를 잘 읽어보고 설정해주시면 됩니다.

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
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):  << Just Press Enter 
OK, successfully used password, moving on...

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

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] N  << Disable Unix Socket Authendication to Enable Password Authentication
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] Y  << Set MariaDB root password
New password:  << Enter root password
Re-enter new password:  << Re-Enter root 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  << Remove Anonymous user
 ... 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] Y  << Disallow root login remotely
 ... 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  << Remove test database
 - 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  << Reload privilege tables
 ... 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!

 

Access MariaDB

위에 설정한 내용을 가지고 로그인을 하여서 테스트 해봅시다.

# mysql -u root -p

이렇게 하면 패스워드를 넣으라 할겁니다.

[root@database deploy]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 52
Server version: 10.4.11-MariaDB MariaDB Server

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)]>

하고 나면 이런식으로 나오게 될겁니다.

성공하셨네요. 그럼 테스트 한번 해보죠.

 

테스트 방법 :

2020/01/19 - [Database] - MariaDB. 간단한 예제

 

MariaDB. 간단한 예제

MariaDB를 설치하고 간단하게 정상적으로 동작하는지 테스트를 하여 보고 싶을 경우가 있습니다. CREATE DATABASE mydb; -- mydb 데이터베이스 생성 USE mydb; -- 기본 데이터베이스로 mydb를 지정 CREATE TABLE m..

mrgamza.tistory.com

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함