All about

M1 맥북에 MariaDB, MySQL를 설치하려고 하니 시행착오를 많이 겪었습니다. MariaDB 부터 과정을 정리합니다.(MySQL은 다른 글에) 이 글을 보시는 분들이 바로 사용할 수 있도록 터미널 결과를 복사해서 글을 작성했습니다.

 

1. homebrew의 install 커맨드로 설치합니다.

root@MacBookAir / % brew install mariadb
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
 https://github.com/Homebrew/brew#donations
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 4 formulae.

==> Downloading https://ghcr.io/v2/homebrew/core/mariadb/manifests/10.7.3
Already downloaded: /Users/root/Library/Caches/Homebrew/downloads/284059719d81ba6f047b6801469dc6e29384559eb0525ed082c153a1490ae770--mariadb-10.7.3.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/mariadb/blobs/sha256:2a58adf34772884da1dcd8810ae75f364fe32cd5583232ef883fb0fc9cd18ee1
Already downloaded: /Users/root/Library/Caches/Homebrew/downloads/726f382d9aa3cfd9ef88994f957e4d5133e63a3970899d32652f16259db73341--mariadb--10.7.3.arm64_big_sur.bottle.tar.gz
==> Pouring mariadb--10.7.3.arm64_big_sur.bottle.tar.gz
==> /opt/homebrew/Cellar/mariadb/10.7.3/bin/mysql_install_db --verbose --user=root --basedir=/opt/homebrew/Cellar/mariadb/10.7.3 --datadir=/opt/homebrew/var/mysql --tmpdir=/tmp
==> 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 restart mariadb after an upgrade:
 brew services restart 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
:beer: /opt/homebrew/Cellar/mariadb/10.7.3: 909 files, 174MB
==> Running `brew cleanup mariadb`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

 

2. mariadb 를 시작합니다, 설치 직후에 아래 커맨드를 입력하면 이미 실행되고 있다는 메세지가 나옵니다.

종료는 "brew services stop mariadb", 재시작은 "brew services restart mariadb" 를 입력합니다.

root@MacBookAir /opt % brew services start mariadb
==> Successfully started `mariadb` (label: homebrew.mxcl.mariadb)

3. mariadb를 실행해봅니다. "mariadb"로도, "mysql"로도 잘 실행됩니다.

root@MacBookAir /opt % mariadb
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.7.3-MariaDB Homebrew
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)]> exit
Bye

root@MacBookAir /opt % mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.7.3-MariaDB Homebrew
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)]>

 

Error case

1. homebrew로 설치했기 때문에, "mysql.server start" 명령어를 사용할 경우 아래와 같이 에러메세지가 출력됩니다. 저는 이걸 몰라서 homebrew로 설치 후에 2번 단계로 실행하지 않았기 때문에 문제가 발생했었습니다.

root@MacBookAir / % mysql.server start
Starting MariaDB
220513 11:36:04 mysqld_safe Logging to ‘/opt/homebrew/var/mysql/MacBookAir.local.err’.
220513 11:36:04 mysqld_safe Starting mariadbd daemon with databases from /opt/homebrew/var/mysql
/opt/homebrew/bin/mysql.server: line 261: log_success_msg: command not found

2. db 설치 과정 중에, 에러가 발생하거나 환경이 꼬였다 싶으면 삭제하고 다시 처음부터 설치하는 경우가 종종 있는데, 이 경우에 겪게된 에러입니다. 어떤 명령어이던 db 실행시 다음과 같은 에러가 발생합니다.

root@MacBookAir workspace % mariadb
ERROR 2002 (HY000): Can’t connect to local server through socket ‘/tmp/mysql.sock’ (2)
root@MacBookAir workspace % mysql
ERROR 2002 (HY000): Can’t connect to local server through socket ‘/tmp/mysql.sock’ (2)

"/opt/homebrew/var" 밑의 "mysql" 디렉토리를 삭제하고 재설치, 이후에 "brew services restart mariadb" 명령어로 서비스를 재시작하면 됩니다.

https://stackoverflow.com/questions/69159310/mac-big-sur-mariadb-will-not-run

root@MacBookAir var % pwd
/opt/homebrew/var
root@MacBookAir var % ls
homebrew	mysql

 

공유하기

facebook twitter kakaoTalk kakaostory naver band
loading