본문 바로가기

DB(SQL)/mysql|maria

[mariaDB] install mariadb on ubuntu 20.04 (feat. maria repo setup)

반응형

참조 사이트

공식 mairadb install url

 

Installing MariaDB .deb Files

Installing MariaDB .deb Files.

mariadb.com

한국어 install 상세? - mairadb install on ubuntu 18.04

 

[mariadb] install mariadb on ubuntu 18.04

ubuntu 18.04에 mairadb 설치 방법 참조 https://mariadb.com/kb/en/installing-mariadb-deb-files/ 업그레이드 https://mariadb.com/kb/en/upgrading/ 업그레이드하기 전에 데이터베이스를 백업하는 것이 가장 좋..

24hours-beginner.tistory.com

mariadb version 선택시 참조해야하는 글

 

[mariadb] mariadb version 선택시 참조해야하는 글

Window functions ONLY_FULL_GROUP_BY mode II 이슈 (fix version : 10.2.43, 10.3.34, 10.4.24, 10.5.15, 10.6.7, 10.7.3) https://24hours-beginner.tistory.com/341#mariadb_upgrade [Mariadb] Window function..

24hours-beginner.tistory.com

 

필수 구성요소 및 작업

1. sudo 권한을 가진 사용자로 로그인

2. apt 업데이트

sudo apt update

참조 사이트

repo download (feat. mariadb repo setup)

repository 는 설치파일? 이라고 생각하면 될것 같다. 다운로드? 해주자.

다운로드 하는 여러가지 방법이 있으나 mariadb repo setup을 이용하여 버전 선택해서 하는게 제일 쉽고 빠르다.

실질적으로 repository는 apt를 사용하는 경우 aptsource.list.d에 내가 어떤 repository를 사용해서 추가하는 단계라고 보면된다.

curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-10.7"

mariadb install

# mariadb repo setup을 통해서 apt list를 수정했으며, 이것을 적용하기 위하여 apt를 update 해준다.
sudo apt update
# 그러면 apt-get을 통해서 install하면 내가 적용한 버전으로 install 해준다.
sudo apt-get install mariadb-server

간단하게 install이 끝났다.

아래 로그를 보면 mariadb_repo_setup에서 내가 원하는 버전을 가져와 apt package list에 갱신하는것을 볼 수 있으며

apt package list 를 apt update를 통해 갱신하여 apt-get install 로 딱히 뭔가 안해도 내가 원하는 version으로 install 되는것을 확인 할 수 있다.

install log

더보기
24시간초보@ubuntu:~$ sudo apt update
[sudo] password for 24시간초보:
Hit:1 http://kr.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://kr.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://kr.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://kr.archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:5 http://kr.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,949 kB]
Get:6 http://kr.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [353 kB]
Get:7 http://kr.archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [15.6 kB]
Get:8 http://kr.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [1,142 kB]
Get:9 http://kr.archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [163 kB]
Get:10 http://kr.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [923 kB]
Get:11 http://kr.archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [20.9 kB]
Get:12 http://kr.archive.ubuntu.com/ubuntu focal-security/main amd64 Packages [1,592 kB]
Get:13 http://kr.archive.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [10.7 kB]
Get:14 http://kr.archive.ubuntu.com/ubuntu focal-security/universe amd64 Packages [710 kB]
Get:15 http://kr.archive.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [14.6 kB]
Fetched 7,229 kB in 5s (1,485 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
24시간초보@ubuntu:~$ curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-10.7"
[sudo] password for 24시간초보:
Sorry, try again.
[sudo] password for 24시간초보:
# [info] Checking for script prerequisites.
# [info] MariaDB Server version 10.7 is valid
# [info] Repository file successfully written to /etc/apt/sources.list.d/mariadb.list
# [info] Adding trusted package signing keys...
# [info] Running apt-get update...
# [info] Done adding trusted package signing keys
24시간초보@ubuntu:~$ sudo apt update
Get:1 https://dlm.mariadb.com/repo/mariadb-server/10.7/repo/ubuntu focal InRelease [7,767 B]
Get:3 https://dlm.mariadb.com/repo/maxscale/latest/apt focal InRelease [6,384 B]
Hit:4 http://kr.archive.ubuntu.com/ubuntu focal InRelease
Hit:5 http://kr.archive.ubuntu.com/ubuntu focal-updates InRelease
Get:6 http://kr.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:2 https://downloads.mariadb.com/Tools/ubuntu focal InRelease
Get:7 http://kr.archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Fetched 236 kB in 3s (84.3 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.
24시간초보@ubuntu:~$ sudo apt-get install mariadb-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfwupdplugin1
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  galera-4 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mariadb-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 libpmem1 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.7 mariadb-client-core-10.7
  mariadb-common mariadb-server-10.7 mariadb-server-core-10.7 socat
Suggested packages:
  libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx mariadb-test
The following NEW packages will be installed:
  galera-4 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mariadb-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 libpmem1 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.7 mariadb-client-core-10.7
  mariadb-common mariadb-server mariadb-server-10.7 mariadb-server-core-10.7 socat
0 upgraded, 27 newly installed, 0 to remove and 2 not upgraded.
Need to get 28.7 MB of archives.
After this operation, 226 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://dlm.mariadb.com/repo/mariadb-server/10.7/repo/ubuntu focal/main amd64 mariadb-common all 1:10.7.4+maria~focal [4,044 B]
Get:2 http://kr.archive.ubuntu.com/ubuntu focal-updates/main amd64 libdbi-perl amd64 1.643-1ubuntu0.1 [730 kB]
Get:3 https://dlm.mariadb.com/repo/mariadb-server/10.7/repo/ubuntu focal/main amd64 galera-4 amd64 26.4.11-focal [12.7 MB]
Get:4 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libconfig-inifiles-perl all 3.000002-1 [40.6 kB]
Get:5 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libpmem1 amd64 1.8-1ubuntu1 [63.8 kB]
Get:6 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 socat amd64 1.7.3.3-2 [323 kB]
Get:7 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libhtml-tagset-perl all 3.20-4 [12.5 kB]
Get:8 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 liburi-perl all 1.76-2 [77.5 kB]
Get:9 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libhtml-parser-perl amd64 3.72-5 [86.3 kB]
Get:10 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libcgi-pm-perl all 4.46-1 [186 kB]
Get:11 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libfcgi-perl amd64 0.79-1 [33.1 kB]
Get:12 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libcgi-fast-perl all 1:2.15-1 [10.5 kB]
Get:13 http://kr.archive.ubuntu.com/ubuntu focal/universe amd64 libdbd-mariadb-perl amd64 1.11-3ubuntu2 [105 kB]
Get:14 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libencode-locale-perl all 1.05-1 [12.3 kB]
Get:15 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libhtml-template-perl all 2.97-1 [59.0 kB]
Get:16 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libtimedate-perl all 2.3200-1 [34.0 kB]
Get:17 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libhttp-date-perl all 6.05-1 [9,920 B]
Get:18 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libio-html-perl all 1.001-1 [14.9 kB]
Get:19 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 liblwp-mediatypes-perl all 6.04-1 [19.5 kB]
Get:20 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libhttp-message-perl all 6.22-1 [76.1 kB]
Get:21 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libterm-readkey-perl amd64 2.38-1build1 [24.6 kB]
Get:22 https://dlm.mariadb.com/repo/mariadb-server/10.7/repo/ubuntu focal/main amd64 libmariadb3 amd64 1:10.7.4+maria~focal [148 kB]
Get:23 https://dlm.mariadb.com/repo/mariadb-server/10.7/repo/ubuntu focal/main amd64 mariadb-client-core-10.7 amd64 1:10.7.4+maria~focal [835 kB]
Get:24 https://dlm.mariadb.com/repo/mariadb-server/10.7/repo/ubuntu focal/main amd64 mariadb-client-10.7 amd64 1:10.7.4+maria~focal [2,419 kB]
Get:25 https://dlm.mariadb.com/repo/mariadb-server/10.7/repo/ubuntu focal/main amd64 mariadb-server-core-10.7 amd64 1:10.7.4+maria~focal [7,206 kB]
Get:26 https://dlm.mariadb.com/repo/mariadb-server/10.7/repo/ubuntu focal/main amd64 mariadb-server-10.7 amd64 1:10.7.4+maria~focal [3,464 kB]
Get:27 https://dlm.mariadb.com/repo/mariadb-server/10.7/repo/ubuntu focal/main amd64 mariadb-server all 1:10.7.4+maria~focal [2,828 B]
Fetched 28.7 MB in 13s (2,203 kB/s)
Preconfiguring packages ...
Selecting previously unselected package mariadb-common.
(Reading database ... 98694 files and directories currently installed.)
Preparing to unpack .../0-mariadb-common_1%3a10.7.4+maria~focal_all.deb ...
Unpacking mariadb-common (1:10.7.4+maria~focal) ...
Selecting previously unselected package galera-4.
Preparing to unpack .../1-galera-4_26.4.11-focal_amd64.deb ...
Unpacking galera-4 (26.4.11-focal) ...
Selecting previously unselected package libdbi-perl:amd64.
Preparing to unpack .../2-libdbi-perl_1.643-1ubuntu0.1_amd64.deb ...
Unpacking libdbi-perl:amd64 (1.643-1ubuntu0.1) ...
Selecting previously unselected package libconfig-inifiles-perl.
Preparing to unpack .../3-libconfig-inifiles-perl_3.000002-1_all.deb ...
Unpacking libconfig-inifiles-perl (3.000002-1) ...
Selecting previously unselected package libmariadb3:amd64.
Preparing to unpack .../4-libmariadb3_1%3a10.7.4+maria~focal_amd64.deb ...
Unpacking libmariadb3:amd64 (1:10.7.4+maria~focal) ...
Selecting previously unselected package mariadb-client-core-10.7.
Preparing to unpack .../5-mariadb-client-core-10.7_1%3a10.7.4+maria~focal_amd64.deb ...
Unpacking mariadb-client-core-10.7 (1:10.7.4+maria~focal) ...
Selecting previously unselected package mariadb-client-10.7.
Preparing to unpack .../6-mariadb-client-10.7_1%3a10.7.4+maria~focal_amd64.deb ...
Unpacking mariadb-client-10.7 (1:10.7.4+maria~focal) ...
Selecting previously unselected package libpmem1:amd64.
Preparing to unpack .../7-libpmem1_1.8-1ubuntu1_amd64.deb ...
Unpacking libpmem1:amd64 (1.8-1ubuntu1) ...
Selecting previously unselected package mariadb-server-core-10.7.
Preparing to unpack .../8-mariadb-server-core-10.7_1%3a10.7.4+maria~focal_amd64.deb ...
Unpacking mariadb-server-core-10.7 (1:10.7.4+maria~focal) ...
Selecting previously unselected package socat.
Preparing to unpack .../9-socat_1.7.3.3-2_amd64.deb ...
Unpacking socat (1.7.3.3-2) ...
Setting up mariadb-common (1:10.7.4+maria~focal) ...
update-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mariadb-server-10.7.
(Reading database ... 99149 files and directories currently installed.)
Preparing to unpack .../00-mariadb-server-10.7_1%3a10.7.4+maria~focal_amd64.deb ...
Unpacking mariadb-server-10.7 (1:10.7.4+maria~focal) ...
Selecting previously unselected package libhtml-tagset-perl.
Preparing to unpack .../01-libhtml-tagset-perl_3.20-4_all.deb ...
Unpacking libhtml-tagset-perl (3.20-4) ...
Selecting previously unselected package liburi-perl.
Preparing to unpack .../02-liburi-perl_1.76-2_all.deb ...
Unpacking liburi-perl (1.76-2) ...
Selecting previously unselected package libhtml-parser-perl.
Preparing to unpack .../03-libhtml-parser-perl_3.72-5_amd64.deb ...
Unpacking libhtml-parser-perl (3.72-5) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../04-libcgi-pm-perl_4.46-1_all.deb ...
Unpacking libcgi-pm-perl (4.46-1) ...
Selecting previously unselected package libfcgi-perl.
Preparing to unpack .../05-libfcgi-perl_0.79-1_amd64.deb ...
Unpacking libfcgi-perl (0.79-1) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../06-libcgi-fast-perl_1%3a2.15-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.15-1) ...
Selecting previously unselected package libdbd-mariadb-perl.
Preparing to unpack .../07-libdbd-mariadb-perl_1.11-3ubuntu2_amd64.deb ...
Unpacking libdbd-mariadb-perl (1.11-3ubuntu2) ...
Selecting previously unselected package libencode-locale-perl.
Preparing to unpack .../08-libencode-locale-perl_1.05-1_all.deb ...
Unpacking libencode-locale-perl (1.05-1) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../09-libhtml-template-perl_2.97-1_all.deb ...
Unpacking libhtml-template-perl (2.97-1) ...
Selecting previously unselected package libtimedate-perl.
Preparing to unpack .../10-libtimedate-perl_2.3200-1_all.deb ...
Unpacking libtimedate-perl (2.3200-1) ...
Selecting previously unselected package libhttp-date-perl.
Preparing to unpack .../11-libhttp-date-perl_6.05-1_all.deb ...
Unpacking libhttp-date-perl (6.05-1) ...
Selecting previously unselected package libio-html-perl.
Preparing to unpack .../12-libio-html-perl_1.001-1_all.deb ...
Unpacking libio-html-perl (1.001-1) ...
Selecting previously unselected package liblwp-mediatypes-perl.
Preparing to unpack .../13-liblwp-mediatypes-perl_6.04-1_all.deb ...
Unpacking liblwp-mediatypes-perl (6.04-1) ...
Selecting previously unselected package libhttp-message-perl.
Preparing to unpack .../14-libhttp-message-perl_6.22-1_all.deb ...
Unpacking libhttp-message-perl (6.22-1) ...
Selecting previously unselected package libterm-readkey-perl.
Preparing to unpack .../15-libterm-readkey-perl_2.38-1build1_amd64.deb ...
Unpacking libterm-readkey-perl (2.38-1build1) ...
Selecting previously unselected package mariadb-server.
Preparing to unpack .../16-mariadb-server_1%3a10.7.4+maria~focal_all.deb ...
Unpacking mariadb-server (1:10.7.4+maria~focal) ...
Setting up libconfig-inifiles-perl (3.000002-1) ...
Setting up galera-4 (26.4.11-focal) ...
Setting up libhtml-tagset-perl (3.20-4) ...
Setting up liblwp-mediatypes-perl (6.04-1) ...
Setting up libencode-locale-perl (1.05-1) ...
Setting up socat (1.7.3.3-2) ...
Setting up libio-html-perl (1.001-1) ...
Setting up libmariadb3:amd64 (1:10.7.4+maria~focal) ...
Setting up libtimedate-perl (2.3200-1) ...
Setting up libfcgi-perl (0.79-1) ...
Setting up libterm-readkey-perl (2.38-1build1) ...
Setting up libpmem1:amd64 (1.8-1ubuntu1) ...
Setting up liburi-perl (1.76-2) ...
Setting up libdbi-perl:amd64 (1.643-1ubuntu0.1) ...
Setting up libhttp-date-perl (6.05-1) ...
Setting up libdbd-mariadb-perl (1.11-3ubuntu2) ...
Setting up mariadb-client-core-10.7 (1:10.7.4+maria~focal) ...
Setting up libhtml-parser-perl (3.72-5) ...
Setting up mariadb-client-10.7 (1:10.7.4+maria~focal) ...
Setting up mariadb-server-core-10.7 (1:10.7.4+maria~focal) ...
Setting up libhttp-message-perl (6.22-1) ...
Setting up libcgi-pm-perl (4.46-1) ...
Setting up libhtml-template-perl (2.97-1) ...
Setting up mariadb-server-10.7 (1:10.7.4+maria~focal) ...
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service.
mariadb-extra.socket is a disabled or a static unit, not starting it.
mariadb-extra.socket is a disabled or a static unit, not starting it.
Setting up libcgi-fast-perl (1:2.15-1) ...
Setting up mariadb-server (1:10.7.4+maria~focal) ...
Processing triggers for systemd (245.4-4ubuntu3.17) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...

 

기본 계정 설정

# mysql 접속
sudo mysql
-- 현재 생성된 유저 확인
select * from mysql.user;

-- 유저 추가
-- 로컬에서만
CREATE USER 'test'@'localhost' IDENTIFIED BY '1234';
-- 외부접속 허용
CREATE USER 'test'@'%' IDENTIFIED BY '1234';
-- ip 지정
CREATE USER 'test'@'192.168.0.1' IDENTIFIED BY '1234';

-- 권한 부여 (모든 데이터베이스 모든 테이블에 대한 모든 권한 획은 / 모든 외부에서 접근 가능)
grant all privileges on *.* to test@'%';

-- 결과 파생
FLUSH PRIVILEGES;

원격접속 허용/기본 DB 설정

# 버전마다 설정 파일 및 경로가 다를 수 있음
vim /etc/mysql/mariadb.conf.d/50-server.cnf

원격 주소 bind-address 변경

기본값(127.0.0.1) > 모두 허용 0.0.0.0 or *

포트 변경

port 3306 (기본값 없음, 변경시 추가하여 변경)

sql mode 변경

sqlmode sql_mode ='' (기본값 없음, 변경시 추가하여 변경)

https://24hours-beginner.tistory.com/159

timezone 변경

log 설정 변경

 

#50-server.cnf

[mysqld]

#
# * Basic Settings
#

user                    = mysql
pid-file                = /run/mysqld/mysqld.pid
basedir                 = /usr
datadir                 = /var/lib/mysql
tmpdir                  = /tmp
lc-messages-dir         = /usr/share/mysql
lc-messages             = en_US
skip-external-locking
sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

# Broken reverse DNS slows down connections considerably and name resolve is
# safe to skip if there are no "host by domain name" access grants
#skip-name-resolve

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 0.0.0.0
port                    = 3306
default-time-zone       = '+9:00'

 

원격접속 안되는 경우 1 Can't connect to server on 'url' (10060)

해결방법 1 - 시작

시작 또는 포트가 다른걸로 되어 있어서 접속이 안되는 경우가 있다.

mariadb 상태 확인

sudo service mariadb status

실행중이지 않은 경우

mariadb 시작

sudo service mariadb start

mariadb 포트 확인

netstat를 통하여 mariadb의 포트가 무엇으로 실행되고 있는지 확인하자.

또한 0.0.0.0이 뚫려있거나 접속하고자 하는 url 이 있는지 보자. >> 해결방법2 or 원격접속 허용

mariadb 는 보통 관리자 계정으로 시작 되기 때문에 sudo 를 붙이지 않으면 PID/Program name이 나오지 않을 수 있다.

PID/program name이 안나오는 경우 sudo 를 붙여 조회해보자.

sudo netstat -lntp

해결방법 2 - bind-address 변경

위에서 말했다시피 접속 ip 권한을 주는 부분이 bind-address 이다. 

bind-address를 해당 ip 또는 0.0.0.0 또는 * 로 주자.

 

해결방법 3 - 방화벽 확인

ubuntu 기준으로 ufw 등의 방화벽이 거부할수 있다.

ufw 라면 아래 명령어로 상태를 확인하고 검색을 통해서 설정을 바꾸자

sudo ufw status

 

해결방법 4 - 네트워크 설정 확인

네트워크 설정 자체에서 포트가 안뚫려 있을 수 있다.

이 경우 네트워크 설정이 어떻게 되어 있냐에 따라서 다르다.

포트포워딩에 대해서 검색해보자.

 

해결방법 5 - host 주소 확인

나란 멍청이 다른 서버에서 디비 환경 만들어 놓았다 ㅋㅋㅋ 이런 멍청이.. ㅠㅠ

자신의 주소를 잘보자.. 

반응형