본문 바로가기
웹 개발

[Maria DB] 설치

by 자는게젤루좋아 2022. 5. 7.

참고로, 이 문서는 Host : Windows 10 Pro, Guest (VM) : Centos 7 + vagrant 환경에서 작성되었습니다. 

 

MariaDB 설치

  • MariaDB 설치 과정입니다.
# MariaDB에 대한 repo 등록
$ vi /etc/yum.repos.d/MariaDB.repo
 
# 다음의 내용들을 입력합니다.(참고로 저는 10.4 버전을 설치하였습니다.)
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/[version 정보]/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
 
# MariaDB를 설치합니다.
$ yum install MariaDB
 
# 다음의 명령어로 MariaDB 설치 정보를 확인할 수 있습니다.
$ rpm -qa | grep MariaDB
MariaDB-compat-10.4.12-1.el7.centos.x86_64
MariaDB-client-10.4.12-1.el7.centos.x86_64
MariaDB-common-10.4.12-1.el7.centos.x86_64
MariaDB-server-10.4.12-1.el7.centos.x86_64
 
# 다음은 설치된 버전정보를 확인할 수 있습니다.
$ mariadb --version
mariadb Ver 15.1 Distrib 10.4.12-MariaDB, for Linux (x86_64) using readline 5.1
 
# mariadb를 실행합니다.
$ systemctl start mariadb
 
# root 비밀번호를 변경합니다.
sudo /usr/bin/mysqladmin -u root password '변경할 비밀번호'
 
# 포트 및 데몬 이름을 확인합니다.
$ netstat -anp | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      -
 
# mariadb에 로그인합니다.
$ mysql -u root -p
Enter password: 설정한 비밀번호 입력
 
# 로그인에 성공하면 다음의 정보들이 콘솔에 표시됩니다.
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 10.4.17-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.
 
# 리눅스 재부팅시 서비스가 자동으로 실행되게 설정합니다.
$ systemctl enable mariadb
$ systemctl is-enabled mariadb
enabled

MariaDB 데이터베이스 생성 및 사용자 생성

  • MariaDB에서 데이터베이스 및 사용자 생성
    • 데이터베이스 명칭 : temp
    • 사용자 명칭 : h****
# mysql에 접속합니다.
$ mysql -u root -p
 
# mysql DB를 사용합니다.
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
# 현재 등록된 host, user, password를 확인할 수 있습니다.
MariaDB [mysql]> select host, user, password from user;
+-----------+-------------+-------------------------------------------+
| Host      | User        | Password                                  |
+-----------+-------------+-------------------------------------------+
| localhost | mariadb.sys |                                           |
| localhost | root        | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| localhost | mysql       | invalid                                   |
| localhost |             |                                           |
| default   |             |                                           |
+-----------+-------------+-------------------------------------------+
5 rows in set (0.002 sec)
 
# h**** 계정을 생성합니다.
MariaDB [mysql]> create user h**** identified by 'h****';
Query OK, 0 rows affected (0.009 sec)
 
# 현재 등록되어 있는 database 목록을 보여줍니다.
MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
 
# temp라는 데이터베이스를 생성합니다.
MariaDB [mysql]> create database temp;
Query OK, 1 row affected (0.023 sec)
 
MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| temp               |
| test               |
+--------------------+
5 rows in set (0.001 sec)
 
# 앞으로 temp 데이터베이스 내부의 테이블은 h**** 계정이 CRUD가 가능하도록 권한을 부여해보겠습니다.
# 이 temp 데이터베이스로 앞으로의 실습을 수행해보겠습니다. :)
MariaDB [mysql]> GRANT ALL PRIVILEGES ON temp.* TO h**** IDENTIFIED BY 'h****';
Query OK, 0 rows affected (0.041 sec)

 

'웹 개발' 카테고리의 다른 글

[Postgres] pg_hba.conf 설정  (0) 2022.05.07
[Postgres] 설치  (0) 2022.05.07

댓글