CentOS 7을 설치하고 Maria DB 10.3 버전을 설치할 것이다.
Maria DB repository 설정
https://downloads.mariadb.org/mariadb/repositories/ 에 접속하면 리눅스 배포본에 따라 각 repository로 부터 설치할 수 있는 방법을 제시해준다. 여기서 제시하는 방법대로 따라하도록 하자.
가장 먼저 해야할 것이 yum repository를 설정하는 것이다. 아래 명령으로 /etc/yum.repos.d/ 디렉토리에 MariaDB.repo 라는 파일을 만들고 그 아래 내용을 넣도록 하자.
$ sudo vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.3 CentOS repository list - created 2019-01-13 00:47 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Maria DB 설치
repository 설정을 했으면 아래 명령으로 YUM을 통해서 Maria DB를 설치할 수 있다.
$sudo yum install MariaDB-server MariaDB-client
설치가 진행되면서 몇 번 묻는 질문에는 모두 y를 선택하면 된다. 설치가 완료되고 나면 아무런 설정을 하지 않아도 기본 설정값으로 실행할 수 있다.
Maria DB 서버 시작
설정 파일을 열어보면 사실 아무것도 설정하고 있는 게 없다. 하지만 그래도 기본값을 가지고 있어서 바로 시작시켜보면 정상적으로 서버가 시작된다. 아래 명령으로 시작 시켜보도록 하자.
# mariadb가 부팅 시 자동 시작되도록 한다. $ sudo systemctl enable mariadb # mariadb를 시작시킨다. $ sudo systemctl start mariadb # 또는 service 명령으로 시작시킬 수도 있다. $ sudo service mariadb start 정상적으로 시작되었는지 아래 명령으로 알아보도록 한다. $ sudo service mariadb status Maria DB 보안 설정하기 서버가 정상적으로 시작되었으면 이제 기본적인 보안 설정을 해야한다. 보안 설정이라니 까다로울 것 같지만 사실 스크립트 하나 실행해주면 된다. 초기 mysql 시절에는 매번 수작업으로 했었던 것 같은데 이제는 제공되는 스크립트 하나를 실행해주면 되니 정말 간단해졌다. 아래 명령을 실행해보자. $ sudo 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 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. Set root password? [Y/n] New password: [root 계정을 위한 비밀번호 설정] 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] [Enter] ... 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] [Enter] ... 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] [Enter] - 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] [Enter] ... 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!