기본 콘텐츠로 건너뛰기

[2023-05-24] MariaDB 설치 on Mac M1

 안녕하세요. 클스 입니다.

오늘은 Mac에 MariaDB를 설치해보고자 합니다. 역시 공부를 하려면 테스트 환경을 구축을 먼저 해야 되겠네요~


[~]$ brew install mariadb

이것저것 필요한 라이브러리 설치하고 한 5분 걸리네요~

==> Pouring mariadb--10.11.3.ventura.bottle.tar.gz

==> /usr/local/Cellar/mariadb/10.11.3/bin/mysql_install_db --verbose --user=keunsookim --basedir=/usr/local/Cellar/mariadb/10.11.3 --datadir=/usr/local/var/mysql --tmpdir=/tmp

설치된 디렉토리 잘 확인해주세요~ 

설치 됐는지 버전을 확인해봅시다. 

[~]$ mariadb -v

ERROR 2002 (HY000): Can't connect to local server through socket '/tmp/mysql.sock' (2)

에러가 나네요 한번에 잘될리가~~  MariaDB가 mysql에서 옆으로 발전한거라 아직도 파일명이 mysql 이 나오네요~

위에 설치한 터미널 로그를 보니 아래 오류가 나네요~

==> Installing virtualenv

==> Pouring virtualenv--20.23.0.arm64_ventura.bottle.tar.gz

Error: The `brew link` step did not complete successfully

설치한 기억이 없는데.... 그래서 삭제 해봅니다.

[~]$ brew uninstall --ignore-dependencies virtualenv

Uninstalling /opt/homebrew/Cellar/virtualenv/20.23.0... (930 files, 14.4MB)

일단 원인을 알아봐야 하겠지만 그래도 혹시나 업데이트를 해봅니다.

[~]$ brew upgrade

그리고 정말 mariadb 가 설치되어 있는지 확인

[~]$ which mariadb

/opt/homebrew/bin/mariadb

혹시나 서비스가 떠있나 확인해봅니다. 

[~]$ brew services list
Name    Status User File
mariadb none
[~]$

MariaDB를 서비스로 실행해 봅니다.

[~]$ brew services start mariadb

==> Successfully started `mariadb` (label: homebrew.mxcl.mariadb)

[~]$


이런 안내도 뜨네요~


다시 버전을 확인 해보니 아래와 같이 뜹니다. 웹에 원인을 이전 파일이 남아있어 문제, 
그래서 재설치가 많았습니다. 
제 경우는 service를 실행안한 상태에서 mariadb -v 를해서 문제가 된것 입니다.

[~]$ mariadb -v
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.11.3-MariaDB Homebrew

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

Reading history-file /Users/keulstar/.mysql_history
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>


데이터 베이스가 잘 설치된 것을 확인할 수 있습니다.

MariaDB [(none)]> quit;

재부팅을 한 이유는 맥이 13.4 업그레이되었네요~ 다시 mariadb 에 접속 해봅니다. 자동으로 서비스가
실행되었네요~ 그런데 무슨 계정으로 접속한건지 ? ㅎㅎ

Last login: Wed May 24 23:19:25 on console
[~]$ mariadb -v
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.11.3-MariaDB Homebrew

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

Reading history-file /Users/keulstar/.mysql_history
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use test
Database changed
MariaDB [test]> show tables;
--------------
show tables
--------------

Empty set (0.001 sec)

MariaDB [test]>

test db에 아무것도 없네요~ 

[~]$ mariadb -uroot
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
[~]$

root로 접속해보려 하니 이런 오류가 나네요~ root로는 접속 못한다.... 역시 sudo 가 최고 입니다.

[~]$ sudo mariadb -u root
Password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.11.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)]>


MariaDB [mysql]>  ALTER user 'root'@'localhost' identified by 'YOURPASSWORD' ;
Query OK, 0 rows affected (0.007 sec)

이렇게 root password를 셋팅해줍니다.

[~]$ mariadb -u root -p
Enter password: YOURPASSWORD 를 입력해줍니다. 아래와 같이 접속되는 것을 확인할 수 있습니다.


Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.11.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)]>


Mariadb 에서는 my.cnf에서 character set 등 여러가지 변수를 변경할 일이 많습니다.

home brew로 설치하면  my.cnf가 어디 있을까요 ?

$ vi /opt/homebrew/etc/my.cnf.  ==> 이 파일에는 별거 없습니다.

다시 찾아 봅니다.

[~]$ mariadb --help | grep my.cnf
/opt/homebrew/etc/my.cnf ~/.my.cnf
                      order of preference, my.cnf, $MYSQL_TCP_PORT,


[~]$ brew services stop mariadb

아래 3개의 파일을 만듭니다.

[stable][/opt/homebrew/etc/my.cnf.d]$ vi client.cnf
[stable][/opt/homebrew/etc/my.cnf.d]$ vi mysql-clients.cnf
[stable][/opt/homebrew/etc/my.cnf.d]$ vi server.cnf

아래와 같이 붙혀 넣어주세요. 그리고 mariadb 재시작 합니다.

/etc/my.cnf.d/client.cnf

[client]
default-character-set=utf8

 

/etc/my.cnf.d/mysql-clients.cnf

[mysql]
default-character-set=utf8

[mysqldump]
default-character-set=utf8

 

/etc/my.cnf.d/server.cnf

[mysqld]
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
MariaDB [(none)]>  show variables like 'c%';

해보시면 이전에 collation_database   latin1 -->  utf8mb3_general_ci 이렇게 변경되어 있습니다.
주의할 점은 문자셋을 변경했으면 기존 db를 삭제하고 다시 만들어주세요

만약 해둔게 많으시다면  아래와 같이 할수 있지만 잘 안되네요~

그래서 무조건 제일 먼저 mariadb 설치 후에는 character set 을 변경하고 재시작 해줘야 합니다.

ALTER DATABASE `test`

DEFAULT CHARACTER SET utf8mb3

DEFAULT COLLATE utf8mb3_general_ci;


안에 있던 테이블도 다 문자셋을 변경해줘야 합니다.


ALTER DATABASE `test`

DEFAULT CHARACTER SET utf8mb3

DEFAULT COLLATE utf8mb3_general_ci;



이상 클스 였습니다.














댓글

이 블로그의 인기 게시물

[quaser.dev][2014-09-14] 윈도우즈(10, 64bit)에 개발환경 설정하기

[quaser.dev][2014-09-14] 윈도우즈(10, 64bit)에 개발환경 설정하기

[2024-10-19] iPhone, iPad에서 ChatGPT로 PDF 생성시 한글 깨짐 해결 방법

iPhone, iPad에서 ChatGPT로 PDF 생성 시 한글 깨짐 해결 방법

[2025-04-16(수)] OpenAI gpt-4.1 시리즈 발표, Anthropic Claude에 대한 생각

OpenAI gpt-4.1 시리즈 발표, Anthropic Claude에 대한 생각 안녕하세요. 클스 입니다. 4/15일자로 openai가 gpt-4.1 시리즈를 발표 했습니다. 현재는 api로만 사용가능합니다. 점차 웹/앱 사용자에게 오픈 될거라 생각 됩니다. 비용상 문제로 4.1-mini, nano를 사용해서 chatbot을 만들어 보고 있습니다. 4o 시리즈 보다는 확실히 빠르고, 답변의 정확도는 올라간 것 같습니다. 앤트로픽 클로드와 비교를 많이 하는데, 업무 시스템 혹은 AI 솔루션을 개발하는 입장에서는 어떤 생태계를 제공하는가가 주요한 결정 입니다. AI관련 인력을 충분히 보유한 회사의 경우는 어떤걸 사용해도 좋을 결과를 가지겠지만 일반적인 챗봇 개발 절차를 보면 다음과 같이 볼 수 있습니다. 1. 문서를 준비한다. 대부분 pdf, text, markdown 2. 문서를 파싱해서 vectordb에 올린다.     - 별도 벡터디비 구성 필요. 어떤 db를 선택할지 고민 필요     - 어떤 Parser를 사용할지, 텍스트 오버래핑은 얼마가 적당한지 고민 필요        (회사의 문서가 워낙 많고, 다양하면 하나하나 테스트 해서 좋은걸 선택하는 것이 어렵다)     - 유사도 측정은 어떤 알고리즘을 써야할지 고민 필요     - llamaindex도 고민해야 함. 3. RAG flow를 만든다.     - langchain을 쓸지, 각 AI 벤더에서 제공하는 sdk를 쓸지 고민 필요       (대부분 락인이 되지 않으려면 langchain을 사용하면 좋지만, 벤더에 특화면 기능 적용이 늦음) 4. 챗봇 UI 앱을 만든다.     - 답변이 text 로 구성되다 보니. 그래프, 이미지등 복합적인 컨텐츠를 재배치 하여 표현하기 상당히 어렵네요. (이건 제가 실력이 모자라서 .. 패스) ...