개발

MariaDB 설치 (우분투)

동고킴 2021. 3. 6. 13:51
반응형

먼저 OS 버전을 확인한다.

ubuntu@instance-20210304-1806:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.2 LTS
Release:	20.04
Codename:	focal

 

마리아DB에 대한 apt 캐시 정책 확인

ubuntu@instance-20210304-1806:~$ sudo apt-cache policy mariadb-server
mariadb-server:
  Installed: (none)
  Candidate: 1:10.3.25-0ubuntu0.20.04.1
  Version table:
     1:10.3.25-0ubuntu0.20.04.1 500
        500 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
     1:10.3.22-1ubuntu1 500
        500 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal/universe amd64 Packages

 

마리아DB 홈페이지 접속 후, OS 및 캐시 버전 선택 후 한국 Mirror 선택하여 가이드에 따라 설치

downloads.mariadb.org/mariadb/repositories

차례대로 실행하면

ubuntu@instance-20210304-1806:~$ sudo apt-get install software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
software-properties-common is already the newest version (0.98.9.4).
software-properties-common set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
ubuntu@instance-20210304-1806:~$ sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
Executing: /tmp/apt-key-gpghome.Bg3hxD0a6X/gpg.1.sh --fetch-keys https://mariadb.org/mariadb_release_signing_key.asc
gpg: requesting key from 'https://mariadb.org/mariadb_release_signing_key.asc'
gpg: key F1656F24C74CD1D8: public key "MariaDB Signing Key <signing-key@mariadb.org>" imported
gpg: Total number processed: 1
gpg:               imported: 1
ubuntu@instance-20210304-1806:~$ sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirror.yongbok.net/mariadb/repo/10.3/ubuntu focal main'
Hit:1 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Get:3 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 https://mirror.yongbok.net/mariadb/repo/10.3/ubuntu focal InRelease [6264 B]
Get:5 https://mirror.yongbok.net/mariadb/repo/10.3/ubuntu focal/main amd64 Packages [16.2 kB]
Get:6 https://mirror.yongbok.net/mariadb/repo/10.3/ubuntu focal/main ppc64el Packages [15.7 kB]
Get:7 https://mirror.yongbok.net/mariadb/repo/10.3/ubuntu focal/main arm64 Packages [15.7 kB]
Get:8 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:9 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [842 kB]
Get:10 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [747 kB]
Fetched 1965 kB in 12s (162 kB/s)
Reading package lists... Done
ubuntu@instance-20210304-1806:~$ sudo apt update
Hit:1 https://mirror.yongbok.net/mariadb/repo/10.3/ubuntu focal InRelease
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Hit:3 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal InRelease
Get:4 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:5 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Fetched 324 kB in 3s (120 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
ubuntu@instance-20210304-1806:~$ sudo apt install mariadb-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  galera-3 libcgi-fast-perl libcgi-pm-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl
  libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmariadb3 libmysqlclient21
  libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server-10.3
  mariadb-server-core-10.3 mysql-common socat
Suggested packages:
  libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx mariadb-test
...
...
...
cessing triggers for systemd (245.4-4ubuntu3.4) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...

설치가 잘되었나 확인. active (running)이다.

ubuntu@instance-20210304-1806:~$ service mysql status
● mariadb.service - MariaDB 10.3.28 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/mariadb.service.d
             └─migrated-from-my.cnf-settings.conf
     Active: active (running) since Sat 2021-03-06 13:30:57 KST; 1min 30s ago
       Docs: man:mysqld(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 37386 (mysqld)
     Status: "Taking your SQL requests now..."
      Tasks: 32 (limit: 1110)
     Memory: 73.9M
     CGroup: /system.slice/mariadb.service
             └─37386 /usr/sbin/mysqld

필요할 경우 테이블 언어 기본셋을 설정한다.

MariaDB 환경설정 위치는 /etc/mysql/conf.d/ 에 파일명이 mariadb.cnf 이다.

mysqld_safe_syslog.cnf 파일만 있다면 신규로 생성한다.

ubuntu@instance-20210304-1806:~$ ll /etc/mysql/conf.d/
total 12
drwxr-xr-x 2 root root 4096 Mar  6 13:30 ./
drwxr-xr-x 4 root root 4096 Mar  6 13:30 ../
-rw-r--r-- 1 root root   36 Feb 19 07:14 mysqld_safe_syslog.cnf
ubuntu@instance-20210304-1806:~$ sudo touch /etc/mysql/conf.d/mariadb.cnf
ubuntu@instance-20210304-1806:~$ ll /etc/mysql/conf.d/
total 12
drwxr-xr-x 2 root root 4096 Mar  6 13:42 ./
drwxr-xr-x 4 root root 4096 Mar  6 13:30 ../
-rw-r--r-- 1 root root    0 Mar  6 13:42 mariadb.cnf
-rw-r--r-- 1 root root   36 Feb 19 07:14 mysqld_safe_syslog.cnf

mariadb.cnf 파일에 언어셋 지정. 아래는 모바일 이모지까지 표현이 가능한 utf8mb4로 언어셋을 지정

하는김에 port도 변경

ubuntu@instance-20210304-1806:~$ sudo vi /etc/mysql/conf.d/mariadb.cnf
ubuntu@instance-20210304-1806:~$ cat /etc/mysql/conf.d/mariadb.cnf
[client]
default-character-set=utf8mb4

[mysql]
default-character-set=utf8mb4

[mysqld]
collation-server = utf8mb4_unicode_ci
character-set-server = utf8mb4
collation_server = utf8mb4_unicode_ci
character_set_server = utf8mb4
port = 3333

MariaDB 재시작

ubuntu@instance-20210304-1806:~$ sudo service mysql restart

우분투 재시작

ubuntu@instance-20210304-1806:~$ sudo shutdown now -r
Connection to 193.123.226.93 closed by remote host.
Connection to 193.123.226.93 closed.

우분투 다시 접속하여, MariaDB 접속

ubuntu@instance-20210304-1806:~$ mysql --user=root mysql -p
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 37
Server version: 10.3.28-MariaDB-1:10.3.28+maria~focal-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

database 확인

MariaDB [mysql]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.000 sec)

port 확인

MariaDB [mysql]> SHOW GLOBAL VARIABLES LIKE 'PORT';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3333  |
+---------------+-------+
1 row in set (0.001 sec)

 

 

MariaDB 설치 끝

 

참고 : itreport.tistory.com/632

반응형