[mariadb] mac 에서 mariadb 설치 및 삭제 By starseat 2024-05-29 10:21:41 db Post Tags `mac` 에서 `brew` 를 통해 mariadb 설치 및 삭제하는 방법이다. # 설치 ## 설치 준비 먼저 `brew update` 를 한다. 이건 그냥 보는건데 `brew search` 를 하여 mariadb 를 확인해본다. ```text > brew search mariadb ==> Formulae mariadb mariadb@10.3 mariadb@11.0 mariadb-connector-c mariadb@10.4 mariadb@11.1 mariadb-connector-odbc mariadb@10.5 mariadb@11.2 mariadb@10.10 mariadb@10.6 qt-mariadb mariadb@10.11 mariadb@10.8 mariadb@10.2 mariadb@10.9 ==> Casks maria navicat-for-mariadb ``` 참고로 `brew install mariadb@10.5` 이런식으로 옛날 버전을 설치할 수 있다. 자세한건 [homebrew mariadb](https://formulae.brew.sh/formula/mariadb) 에서 확인하면 된다. ## 설치 `brew install mariadb` 를 하여 설치한다. ```text > brew install mariadb ==> Downloading https://formulae.brew.sh/api/formula.jws.json ######################################################################### 100.0% ==> Downloading https://formulae.brew.sh/api/cask.jws.json ######################################################################### 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/mariadb/manifests/11.3.2 ... 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 ``` ### 설치 확인 (버전 확인) ```text > mariadb -V mariadb from 11.3.2-MariaDB, client 15.2 for osx10.19 (arm64) using EditLine wrapper ``` ## 실행 설치가 완료 되었으니 `brew servies start mariadb` 명령어로 실행한다. ```text > brew services start mariadb ==> Successfully started `mariadb` (label: homebrew.mxcl.mariadb) ``` ## 초기 설정 - root 비밀번호 변경 먼저 `mariadb` 명령어로 mariadb 에 접속한 후 ```text > mariadb Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 63 Server version: 11.3.2-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 root 의 비밀번호를 변경한다. - use mysql; <- db 변경 - set password for 'root'@'localhost'=password('비밀번호'); <- 비밀전호 설정. - flush privileges; <- 적용 ```text MariaDB [(none)]> use mysql; Database changed MariaDB [mysql]> set password for 'root'@'localhost'=password('test123'); Query OK, 0 rows affected (0.006 sec) MariaDB [mysql]> flush privileges; Query OK, 0 rows affected (0.001 sec) MariaDB [mysql]> \q Bye ``` # 보안 설정 먼저 혹시 모를 사고를 방지하기 위해 mariadb 를 종료한다. ```text > brew services stop mariadb ``` 보안 설정을 진행한다. (이 부분은 다른 블로그를 참조하였다.) ```text // sudo : 관리자권한으로 다음을 실행하라는 명령어입니다. % sudo mariadb-secure-installation // 맥의 루트계정 비밀번호를 입력합니다. 따로 설정되어있지 않을 경우 엔터키를 누르면 진행됩니다. Password: NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here. // 현재 마리아디비 루트계정의 비밀번호(위에서 설정한 비밀번호)를 입력해줍니다. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. // 마리아디비 계정을 유닉스 소켓을 통해 인증하겠습니까? 아니오. Switch to unix_socket authentication [Y/n] n ... skipping. You already have your root account protected, so you can safely answer 'n'. // 현재 마리아디비 루트 계정의 비밀번호를 바꾸시겠습니까? 아니오. Change the root password? [Y/n] n ... skipping. By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. // 익명사용자 계정을 삭제하시겠습니까? 예. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. // 루트계정의 원격접속을 차단하시겠습니까? 아니오. Disallow root login remotely? [Y/n] n ... skipping. By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. // 테스트 데이터베이스와 그 접근정보를 제거하시겠습니까? 예. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. // 권한정보를 새로고침 하시겠습니까? 예. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB! ``` 설정이 완료 되었으니 mariadb 를 다시 실행한다. ```text > brew services start mariadb ``` # 삭제 - 서비스 중지 및 삭제 ```text > brew services stop mariadb > brew uninstall mariadb ``` - 관련 설정 삭제 ```text > cd /opt/homebrew > rm -rf var/mysql > rm r-f etc/my.cnf* ``` # 참조 - [https://velog.io/@jthugg/install-mariadb-in-mac-os-arm64](https://velog.io/@jthugg/install-mariadb-in-mac-os-arm64) Previous Post [MySQL] Windows 환경 root 비밀번호 변경 Next Post -