DB/MySQL

[CentOS] MariaDB 설치부터 데이터베이스 생성까지

통통만두 2020. 12. 11. 22:55
반응형

안녕하세요. CentOS 에 MariaDB 설치부터 데이터베이스 생성까지 알아보도록 하겠습니다.

1. Repo 설정

sudo 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

여기서는 MariaDB 10.5 버전을 설치하도록 하겠습니다. 다른 버전을 설치하시려면 baseurl 안의 버전을 변경해주시면 됩니다.

 

2. 설치

sudo yum install MariaDB
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: d36uatko69830t.cloudfront.net
 * extras: d36uatko69830t.cloudfront.net
 * updates: d36uatko69830t.cloudfront.net
base                                                                                                                                                                                                                      | 3.6 kB  00:00:00     
extras                                                                                                                                                                                                                    | 2.9 kB  00:00:00     
mariadb                                                                                                                                                                                                                   | 2.9 kB  00:00:00     
nginx                                                                                                                                                                                                                     | 2.9 kB  00:00:00     
nodesource                                                                                                                                                                                                                | 2.5 kB  00:00:00     
updates                                                                                                                                                                                                                   | 2.9 kB  00:00:00     
(1/6): extras/7/x86_64/primary_db                                                                                                                                                                                         | 222 kB  00:00:00     
(2/6): base/7/x86_64/primary_db                                                                                                                                                                                           | 6.1 MB  00:00:00     
(3/6): nodesource/x86_64/primary_db                                                                                                                                                                                       |  49 kB  00:00:00     
(4/6): updates/7/x86_64/primary_db                                                                                                                                                                                        | 3.7 MB  00:00:00     
(5/6): nginx/x86_64/primary_db                                                                                                                                                                                            |  59 kB  00:00:01     
(6/6): mariadb/primary_db                                                                                                                                                                                                 |  70 kB  00:00:01     
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-server.x86_64 0:10.5.8-1.el7.centos will be installed
--> Processing Dependency: perl(DBI) for package: MariaDB-server-10.5.8-1.el7.centos.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: MariaDB-server-10.5.8-1.el7.centos.x86_64
--> Processing Dependency: MariaDB-client for package: MariaDB-server-10.5.8-1.el7.centos.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: MariaDB-server-10.5.8-1.el7.centos.x86_64
--> Processing Dependency: galera-4 for package: MariaDB-server-10.5.8-1.el7.centos.x86_64
--> Processing Dependency: MariaDB-common for package: MariaDB-server-10.5.8-1.el7.centos.x86_64
--> Processing Dependency: lsof for package: MariaDB-server-10.5.8-1.el7.centos.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: MariaDB-server-10.5.8-1.el7.centos.x86_64
--> Processing Dependency: libpcre2-8.so.0()(64bit) for package: MariaDB-server-10.5.8-1.el7.centos.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: MariaDB-server-10.5.8-1.el7.centos.x86_64
--> Running transaction check
---> Package MariaDB-client.x86_64 0:10.5.8-1.el7.centos will be installed
---> Package MariaDB-common.x86_64 0:10.5.8-1.el7.centos will be installed
--> Processing Dependency: MariaDB-compat for package: MariaDB-common-10.5.8-1.el7.centos.x86_64
---> Package galera-4.x86_64 0:26.4.6-1.el7.centos will be installed
--> Processing Dependency: socat for package: galera-4-26.4.6-1.el7.centos.x86_64
--> Processing Dependency: libboost_program_options.so.1.53.0()(64bit) for package: galera-4-26.4.6-1.el7.centos.x86_64
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package lsof.x86_64 0:4.87-6.el7 will be installed
---> Package pcre2.x86_64 0:10.23-2.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Running transaction check
---> Package MariaDB-compat.x86_64 0:10.5.8-1.el7.centos will be obsoleting
---> Package boost-program-options.x86_64 0:1.53.0-28.el7 will be installed
---> Package mariadb-libs.x86_64 1:5.5.64-1.el7 will be obsoleted
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
---> Package socat.x86_64 0:1.7.3.2-2.el7 will be installed
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================================================================
 Package                                                            Arch                                              Version                                                           Repository                                          Size
=================================================================================================================================================================================================================================================
Installing:
 MariaDB-compat                                                     x86_64                                            10.5.8-1.el7.centos                                               mariadb                                            2.2 M
     replacing  mariadb-libs.x86_64 1:5.5.64-1.el7
 MariaDB-server                                                     x86_64                                            10.5.8-1.el7.centos                                               mariadb                                             26 M
Installing for dependencies:
 MariaDB-client                                                     x86_64                                            10.5.8-1.el7.centos                                               mariadb                                             13 M
 MariaDB-common                                                     x86_64                                            10.5.8-1.el7.centos                                               mariadb                                             81 k
 boost-program-options                                              x86_64                                            1.53.0-28.el7                                                     base                                               156 k
 galera-4                                                           x86_64                                            26.4.6-1.el7.centos                                               mariadb                                            9.5 M
 libaio                                                             x86_64                                            0.3.109-13.el7                                                    base                                                24 k
 lsof                                                               x86_64                                            4.87-6.el7                                                        base                                               331 k
 pcre2                                                              x86_64                                            10.23-2.el7                                                       base                                               201 k
 perl-Compress-Raw-Bzip2                                            x86_64                                            2.061-3.el7                                                       base                                                32 k
 perl-Compress-Raw-Zlib                                             x86_64                                            1:2.061-4.el7                                                     base                                                57 k
 perl-DBI                                                           x86_64                                            1.627-4.el7                                                       base                                               802 k
 perl-Data-Dumper                                                   x86_64                                            2.145-3.el7                                                       base                                                47 k
 perl-IO-Compress                                                   noarch                                            2.061-2.el7                                                       base                                               260 k
 perl-Net-Daemon                                                    noarch                                            0.48-5.el7                                                        base                                                51 k
 perl-PlRPC                                                         noarch                                            0.2020-14.el7                                                     base                                                36 k
 socat                                                              x86_64                                            1.7.3.2-2.el7                                                     base                                               290 k

Transaction Summary
=================================================================================================================================================================================================================================================
Install  2 Packages (+15 Dependent packages)

Total download size: 53 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mariadb/packages/MariaDB-common-10.5.8-1.el7.centos.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY                                                          ]  0.0 B/s |  31 kB  --:--:-- ETA 
Public key for MariaDB-common-10.5.8-1.el7.centos.x86_64.rpm is not installed
(1/17): MariaDB-common-10.5.8-1.el7.centos.x86_64.rpm                                                                                                                                                                     |  81 kB  00:00:01     
(2/17): MariaDB-compat-10.5.8-1.el7.centos.x86_64.rpm                                                                                                                                                                     | 2.2 MB  00:00:03     
(3/17): boost-program-options-1.53.0-28.el7.x86_64.rpm                                                                                                                                                                    | 156 kB  00:00:00     
(4/17): MariaDB-client-10.5.8-1.el7.centos.x86_64.rpm                                                                                                                                                                     |  13 MB  00:00:07     
(5/17): libaio-0.3.109-13.el7.x86_64.rpm                                                                                                                                                                                  |  24 kB  00:00:00     
(6/17): pcre2-10.23-2.el7.x86_64.rpm                                                                                                                                                                                      | 201 kB  00:00:00     
(7/17): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                                                                                                                                                                    |  32 kB  00:00:00     
(8/17): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                                                                                                                                     |  57 kB  00:00:00     
(9/17): perl-DBI-1.627-4.el7.x86_64.rpm                                                                                                                                                                                   | 802 kB  00:00:00     
(10/17): perl-Data-Dumper-2.145-3.el7.x86_64.rpm                                                                                                                                                                          |  47 kB  00:00:00     
(11/17): lsof-4.87-6.el7.x86_64.rpm                                                                                                                                                                                       | 331 kB  00:00:00     
(12/17): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                                                                                                                                          | 260 kB  00:00:00     
(13/17): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                                                                                                                                            |  51 kB  00:00:00     
(14/17): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                                                                                                                                              |  36 kB  00:00:00     
(15/17): socat-1.7.3.2-2.el7.x86_64.rpm                                                                                                                                                                                   | 290 kB  00:00:00     
(16/17): galera-4-26.4.6-1.el7.centos.x86_64.rpm                                                                                                                                                                          | 9.5 MB  00:00:01     
(17/17): MariaDB-server-10.5.8-1.el7.centos.x86_64.rpm                                                                                                                                                                    |  26 MB  00:00:04     
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                            5.7 MB/s |  53 MB  00:00:09     
Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Importing GPG key 0x1BB943DB:
 Userid     : "MariaDB Package Signing Key <package-signing-key@mariadb.org>"
 Fingerprint: 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db
 From       : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libaio-0.3.109-13.el7.x86_64                                                                                                                                                                                                 1/18 
  Installing : lsof-4.87-6.el7.x86_64                                                                                                                                                                                                       2/18 
  Installing : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                                                                                          3/18 
  Installing : pcre2-10.23-2.el7.x86_64                                                                                                                                                                                                     4/18 
  Installing : MariaDB-common-10.5.8-1.el7.centos.x86_64                                                                                                                                                                                    5/18 
  Installing : MariaDB-compat-10.5.8-1.el7.centos.x86_64                                                                                                                                                                                    6/18 
  Installing : MariaDB-client-10.5.8-1.el7.centos.x86_64                                                                                                                                                                                    7/18 
  Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                                                                                                  8/18 
  Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                                                                                                   9/18 
  Installing : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                                                                                         10/18 
  Installing : boost-program-options-1.53.0-28.el7.x86_64                                                                                                                                                                                  11/18 
  Installing : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                                                                                           12/18 
  Installing : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                                                                                             13/18 
  Installing : perl-DBI-1.627-4.el7.x86_64                                                                                                                                                                                                 14/18 
  Installing : socat-1.7.3.2-2.el7.x86_64                                                                                                                                                                                                  15/18 
  Installing : galera-4-26.4.6-1.el7.centos.x86_64                                                                                                                                                                                         16/18 
  Installing : MariaDB-server-10.5.8-1.el7.centos.x86_64                                                                                                                                                                                   17/18 


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at https://mariadb.com/kb or the
MySQL manual for more instructions.

Please report any problems at https://mariadb.org/jira

The latest information about MariaDB is available at https://mariadb.org/.
You can find additional information about the MySQL part at:
https://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

  Erasing    : 1:mariadb-libs-5.5.64-1.el7.x86_64                                                                                                                                                                                          18/18 
  Verifying  : galera-4-26.4.6-1.el7.centos.x86_64                                                                                                                                                                                          1/18 
  Verifying  : pcre2-10.23-2.el7.x86_64                                                                                                                                                                                                     2/18 
  Verifying  : socat-1.7.3.2-2.el7.x86_64                                                                                                                                                                                                   3/18 
  Verifying  : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                                                                                            4/18 
  Verifying  : MariaDB-client-10.5.8-1.el7.centos.x86_64                                                                                                                                                                                    5/18 
  Verifying  : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                                                                                          6/18 
  Verifying  : MariaDB-compat-10.5.8-1.el7.centos.x86_64                                                                                                                                                                                    7/18 
  Verifying  : boost-program-options-1.53.0-28.el7.x86_64                                                                                                                                                                                   8/18 
  Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                                                                                                   9/18 
  Verifying  : lsof-4.87-6.el7.x86_64                                                                                                                                                                                                      10/18 
  Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                                                                                                 11/18 
  Verifying  : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                                                                                             12/18 
  Verifying  : MariaDB-common-10.5.8-1.el7.centos.x86_64                                                                                                                                                                                   13/18 
  Verifying  : MariaDB-server-10.5.8-1.el7.centos.x86_64                                                                                                                                                                                   14/18 
  Verifying  : libaio-0.3.109-13.el7.x86_64                                                                                                                                                                                                15/18 
  Verifying  : perl-DBI-1.627-4.el7.x86_64                                                                                                                                                                                                 16/18 
  Verifying  : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                                                                                         17/18 
  Verifying  : 1:mariadb-libs-5.5.64-1.el7.x86_64                                                                                                                                                                                          18/18 

Installed:
  MariaDB-compat.x86_64 0:10.5.8-1.el7.centos                                                                             MariaDB-server.x86_64 0:10.5.8-1.el7.centos                                                                            

Dependency Installed:
  MariaDB-client.x86_64 0:10.5.8-1.el7.centos       MariaDB-common.x86_64 0:10.5.8-1.el7.centos       boost-program-options.x86_64 0:1.53.0-28.el7       galera-4.x86_64 0:26.4.6-1.el7.centos             libaio.x86_64 0:0.3.109-13.el7      
  lsof.x86_64 0:4.87-6.el7                          pcre2.x86_64 0:10.23-2.el7                        perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7       perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7       perl-DBI.x86_64 0:1.627-4.el7       
  perl-Data-Dumper.x86_64 0:2.145-3.el7             perl-IO-Compress.noarch 0:2.061-2.el7             perl-Net-Daemon.noarch 0:0.48-5.el7                perl-PlRPC.noarch 0:0.2020-14.el7                 socat.x86_64 0:1.7.3.2-2.el7        

Replaced:
  mariadb-libs.x86_64 1:5.5.64-1.el7                                                                                                                                                                                                             

Complete!

 

3. 설치 확인

rpm -qa | grep MariaDB
MariaDB-common-10.5.8-1.el7.centos.x86_64
MariaDB-client-10.5.8-1.el7.centos.x86_64
MariaDB-server-10.5.8-1.el7.centos.x86_64
MariaDB-compat-10.5.8-1.el7.centos.x86_64

 

4. 서비스 시작

sudo systemctl start mariadb

 

5. root 비밀번호 변경

sudo /usr/bin/mysqladmin -u root password 'password'

 

6. 서비스 확인

netstat -anp | grep 3306
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::3306                 :::*                    LISTEN      -

 

7. 접속

mysql -u root -p
Enter password: password
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 10.5.8-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)]>

 

8. 데이터베이스 생성

create database marsland;

 

9. 계정 생성

create user 'marsland'@'%' identified by 'password';

 

10. 권한 부여

grant all privileges on marsland.* to 'marsland'@'%';

FLUSH PRIVILEGES;

 

자 여기까지 했다면 정상적으로 접속이 되는지 확인을 해 볼 차례입니다.

DBeaver에서 MariaDB연결 설정 화면

 

연결이 성공적으로 이루어진 화면

 

 

지금까지 CentOS 에 MariaDB를 설치하고 데이터베이스 생성, 그리고 계정생성, 연결까지 알아보았습니다.

반응형