맥(Mac)에 마리아디비(MariaDB) 설치하기
홈브루(Homebrew) 로 macOS애 MariaDB Server 설치
1. 설치환경
M2 맥북
macOS Sonoma 14.3
홈브류(Homebrew) 로 macOS에 MariaDB Server 설치
https://mariadb.com/kb/ko/installing-mariadb-on-macos-using-homebrew/
2. 설치
(1) 홈브류(Homebrew) 업데이트
터미널에 업데이트 명령어를 입력하여 홈브류(Homebrew)를 업데이트한다.
만약, 홈브류가 설치되어 있지 않다면 먼저 홈브류를 설치 후 진행한다.
% brew update
최신버전이라면 Alreay up-to-date 가 출력되며, 아니라면 업데이트가 진행된다.
(2) 마리아디비(MariaDB) 설치
터미널에 MariaDB 설치 명령어를 입력한다.
% brew install mariadb
% brew install mariadb
==> Downloading https://ghcr.io/v2/homebrew/core/mariadb/manifests/11.2.2
######################################################################### 100.0%
==> Fetching dependencies for mariadb: mecab, mecab-ipadic, msgpack, ca-certificates, openssl@3, groonga, pcre2, lz4, xz and zstd
==> Downloading https://ghcr.io/v2/homebrew/core/mecab/manifests/0.996-3
######################################################################### 100.0%
==> Fetching mecab
==> Downloading https://ghcr.io/v2/homebrew/core/mecab/blobs/sha256:0daf2cce68e6
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/mecab-ipadic/manifests/2.7.0-20
######################################################################### 100.0%
==> Fetching mecab-ipadic
==> Downloading https://ghcr.io/v2/homebrew/core/mecab-ipadic/blobs/sha256:99d6b
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/msgpack/manifests/6.0.0
######################################################################### 100.0%
==> Fetching msgpack
==> Downloading https://ghcr.io/v2/homebrew/core/msgpack/blobs/sha256:fdb7af2f6a
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2023-
######################################################################### 100.0%
==> Fetching ca-certificates
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:5c
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/manifests/3.2.0_1
######################################################################### 100.0%
==> Fetching openssl@3
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/blobs/sha256:6519a6ff
####################################################### 76.6%######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/groonga/manifests/13.1.0
######################################################################### 100.0%
==> Fetching groonga
==> Downloading https://ghcr.io/v2/homebrew/core/groonga/blobs/sha256:9f13363a16
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/pcre2/manifests/10.42
######################################################################### 100.0%
==> Fetching pcre2
==> Downloading https://ghcr.io/v2/homebrew/core/pcre2/blobs/sha256:f9abacbf5d8f
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/manifests/1.9.4
######################################################################### 100.0%
==> Fetching lz4
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/blobs/sha256:5a8b7116d978e4
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/xz/manifests/5.4.5
######################################################################### 100.0%
==> Fetching xz
==> Downloading https://ghcr.io/v2/homebrew/core/xz/blobs/sha256:ea718d075502d44
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/manifests/1.5.5-1
######################################################################### 100.0%
==> Fetching zstd
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/blobs/sha256:4712aabcc9f27
######################################################################### 100.0%
==> Fetching mariadb
==> Downloading https://ghcr.io/v2/homebrew/core/mariadb/blobs/sha256:68ee86e9ef
######################################################################### 100.0%
==> Installing dependencies for mariadb: mecab, mecab-ipadic, msgpack, ca-certificates, openssl@3, groonga, pcre2, lz4, xz and zstd
==> Installing mariadb dependency: mecab
==> Downloading https://ghcr.io/v2/homebrew/core/mecab/manifests/0.996-3
Already downloaded: /Users/jim...../Library/Caches/Homebrew/downloads/21431e68751945bd7900be15e222a38b4402841088e6d5669b4f48c56dc614b3--mecab-0.996-3.bottle_manifest.json
==> Pouring mecab--0.996.arm64_sonoma.bottle.3.tar.gz
==> Downloading https://formulae.brew.sh/api/formula.jws.json
🍺 /opt/homebrew/Cellar/mecab/0.996: 18 files, 4.1MB
==> Installing mariadb dependency: mecab-ipadic
==> Downloading https://ghcr.io/v2/homebrew/core/mecab-ipadic/manifests/2.7.0-20
Already downloaded: /Users/jim...../Library/Caches/Homebrew/downloads/011316e018929eb52aa0a17e2d6634fe3804c07bf44859f3cc7a0b4baf0e3cea--mecab-ipadic-2.7.0-20070801.bottle_manifest.json
==> Pouring mecab-ipadic--2.7.0-20070801.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/mecab-ipadic/2.7.0-20070801: 14 files, 39.7MB
==> Installing mariadb dependency: msgpack
==> Downloading https://ghcr.io/v2/homebrew/core/msgpack/manifests/6.0.0
Already downloaded: /Users/jim...../Library/Caches/Homebrew/downloads/3533ae77dcecb13cc631f865cf4137bba537acdaea45d1c9a206585bc94a434b--msgpack-6.0.0.bottle_manifest.json
==> Pouring msgpack--6.0.0.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/msgpack/6.0.0: 38 files, 203.8KB
==> Installing mariadb dependency: ca-certificates
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2023-
Already downloaded: /Users/jim...../Library/Caches/Homebrew/downloads/13aa86e429e05d02a76005d1881eaf625091a5ac4dc7d7674c706d12ba48796a--ca-certificates-2023-12-12.bottle_manifest.json
==> Pouring ca-certificates--2023-12-12.all.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺 /opt/homebrew/Cellar/ca-certificates/2023-12-12: 3 files, 226.7KB
==> Installing mariadb dependency: openssl@3
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/manifests/3.2.0_1
Already downloaded: /Users/jim...../Library/Caches/Homebrew/downloads/8e5415de690efd057f74775ab4b808fed9a50bf29c34ee9cb52118d189ef73a9--openssl@3-3.2.0_1.bottle_manifest.json
==> Pouring openssl@3--3.2.0_1.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/openssl@3/3.2.0_1: 6,805 files, 31.9MB
==> Installing mariadb dependency: groonga
==> Downloading https://ghcr.io/v2/homebrew/core/groonga/manifests/13.1.0
Already downloaded: /Users/jim...../Library/Caches/Homebrew/downloads/292cc875ca149cddb21f16f4749097dce229ef5e5ed492fd70a4e95ad1ad2016--groonga-13.1.0.bottle_manifest.json
==> Pouring groonga--13.1.0.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/groonga/13.1.0: 889 files, 83.6MB
==> Installing mariadb dependency: pcre2
==> Downloading https://ghcr.io/v2/homebrew/core/pcre2/manifests/10.42
Already downloaded: /Users/jim...../Library/Caches/Homebrew/downloads/6a53794fcaabc5cc5e05b19c02ca9c4c5f2cb9a4d65a5790a6841146465b040f--pcre2-10.42.bottle_manifest.json
==> Pouring pcre2--10.42.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/pcre2/10.42: 230 files, 6.1MB
==> Installing mariadb dependency: lz4
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/manifests/1.9.4
Already downloaded: /Users/jim...../Library/Caches/Homebrew/downloads/379e59b981667f9585b33a2ff318769d8edca3ce6fd2e9a67ed291ae3e0cc872--lz4-1.9.4.bottle_manifest.json
==> Pouring lz4--1.9.4.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/lz4/1.9.4: 22 files, 636.0KB
==> Installing mariadb dependency: xz
==> Downloading https://ghcr.io/v2/homebrew/core/xz/manifests/5.4.5
Already downloaded: /Users/jim...../Library/Caches/Homebrew/downloads/4e81fda476fb634a7e1ac650019bfe768a65d6c387015992df4cd75adf9b3fce--xz-5.4.5.bottle_manifest.json
==> Pouring xz--5.4.5.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/xz/5.4.5: 163 files, 2.6MB
==> Installing mariadb dependency: zstd
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/manifests/1.5.5-1
Already downloaded: /Users/jim...../Library/Caches/Homebrew/downloads/fc13698599720a53800064b40cddd854399651cf8760d9b0e46092f2e8da701a--zstd-1.5.5-1.bottle_manifest.json
==> Pouring zstd--1.5.5.arm64_sonoma.bottle.1.tar.gz
🍺 /opt/homebrew/Cellar/zstd/1.5.5: 31 files, 2MB
==> Installing mariadb
==> Pouring mariadb--11.2.2.arm64_sonoma.bottle.tar.gz
==> /opt/homebrew/Cellar/mariadb/11.2.2/bin/mysql_install_db --verbose --user=ji
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
MySQL is configured to only allow connections from localhost by default
To start mariadb now and restart at login:
brew services start mariadb
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/mariadb/bin/mysqld_safe --datadir\=/opt/homebrew/var/mysql
==> Summary
🍺 /opt/homebrew/Cellar/mariadb/11.2.2: 941 files, 212.1MB
==> Running `brew cleanup mariadb`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> mariadb
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
MySQL is configured to only allow connections from localhost by default
To start mariadb now and restart at login:
brew services start mariadb
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/mariadb/bin/mysqld_safe --datadir\=/opt/homebrew/var/mysql
(참고)
애플 실리콘 맥(M1, M2)의 경우 기존 인텔 맥과 저장되는 위치가 다르므로 주의해야한다.
m1, m2 와같은 애플 실리콘 맥인 경우 설치 경로가 「 /usr/local/ 」 이 아니고 「 /opt/homebrew/ 」 인 경우가 많아 주의해야한다.
(3) 마리아디비(MariaDB) 설치확인
마리아디비(MariaDB) 버전 확인 명령어를 통해 설치를 확인한다.
% mariadb -V
MariaDB 11.2.2 버전이 설치된 것을 확인할 수 있다.
3. 실행
(1) 설치 완료 후 다음 명령어로 MariaDB Server 를 실행한다.
% mysql.server start
(2) MariaDB 접속
% mariadb
(3) 데이터베이스 확인
다음 명령어로 현재 데이터베이스를 확인할 수 있다.
show databases;
다음 명령어로 mysql 을 선택하면 none 이 mysql 로 변경되는 것을 확인할 수 있다.
use mysql
4. 루트(root) 계정 설정
(1) 루트(root) 계정 확인
다음 sql 문을 실행하면 user 테이블에서 host, user, password 문을 표시해준다.
select host, user, password from user;
루트(root) 계정의 Password가 invalid 인 것을 확인할 수 있다. 그러므로 비밀번호를 설정해줄 필요가 있다.
(2) 루트(root) 계정 비밀번호 설정
# 비밀번호 설정 (MariaDB 10.5 이상 버전은 mysql의 user 테이블이 뷰이다.)
set password for 'root'@'localhost'=password('설정 할 비밀번호')
# 변경한 내용 반영
flush privileges;
예를들어 비밀번호를 root 라고 설정한다면 다음과 같이 하면 된다.
(3) 비밀번호 설정 확인
다시 user 테이블을 select 문으로 확인한다.
select host, user, password from user;
루트(root) 계정의 Password가 암호화되어 설정된 것을 확인할 수 있다.
\q 를 입력하여 종료한다.
■ MariaDB 실행 명령어
# MariaDB 서버 실행
brew services start mariadb
# MariaDB 서버 중지
brew services stop mariadb
# MariaDB 서버 재시작
brew services restart mariadb
# MariaDB 서버 실행 확인
brew services list
■ MariaDB 업그레이드 명령어
# 홈브류 업데이트
brew update
# MariaDB Server 업데이트
brew upgrade mariadb