[MariaDB] Mac MariaDB 설치 및 조작

DayeWay·2021년 6월 9일
4
post-thumbnail

J2KB 3기에서 만난 TBWP(Text Based Web Presentation) 팀원들과 프로젝트를 진행하기에 앞서 백엔드 단에서 Mysql이 아닌 오픈소스인 MariaDB를 사용하기로 했다. (요즘 대세는 mariadb 이지 않을까 한다!)

나는 아직 개발 초초초급 단계이기 때문에 적어두지 않으면 까먹을 것 같아 오늘 삽질한 내용들을 적어보려 한다 ㅎ_ㅎ

1. MariaDB install in Mac

맥북 유저라면 애용하게 되는 homebrew를 이용하여 설치했다.

brew install mariadb

homebrew가 업데이트가 되고~ mariadb가 깔끔하게 설치가 된다
(필자는 sudo 패스워드를 mariadb 초기 패스워드로 착각하여 몇번 uninstall 했었다는....)

설치가 완료되었다면 실행시켜보자
brew로 설치한 서비스들을 시작할때는 아래와 같은 구문을 쓰도록 하자

동작 : brew services start mariadb
중지 : brew services stop mariadb

mariadb를 동작시켰다면 실제로 동작하는지 확인!!

brew services list

그럼 brew로 설치된 서비스들의 동작 여부를 확인할 수 있을 것이다

2. MariaDB root 계정 생성

Mysql과 마찬가지로 MariaDB도 설치하였다면 관리자 계정인 root 계정을 설정해야한다.

sudo mariadb-secure-installation

sudo를 이용해 진입하면 sudo 패스워드를 입력해야한다. (필자는 이 곳에서 당황하여 2시간 잡아먹은듯 하다 ㅠㅠ)

1. 초기 root 계정의 비밀번호를 요구하는 Current Password가 있을텐데 여기선 Enter로 넘어가도 된다

2. mariadb setting이 이루어질텐데, 아래와 같이 설정하면 무방할듯

(추후에 dbeaver와 연동할때 권한 열어둘걸...)

중간에 패스워드 설정해주고 쭉 나아가면 된다.(패스워드 잊지 말아라!)

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] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

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!

3. mariadb root 계정에 접속

mysql -u root -p

위 내용을 작성하고 설정해준 패스워드를 쳐주면
mariadb 입성 성공!

참고로, mariadb는 mysql의 브랜치에서 뻗어나온 것이므로 mysql의 문법과 동일하다고 보면 된다.
쿼리를 작성하기 전에

use mysql 을 이용하면 mysql 문법으로 쿼리 작성이 가능하다!

필자는 mysql 문법만 공부해서 너무나도 찰떡인 db문을 만난것 같아 기쁘다 ㅎㅎ

profile
엔지니어에서 개발자로 가는 중

2개의 댓글

comment-user-thumbnail
2021년 9월 25일

감사합니다 ㅎㅎ 많은 도움되었습니다~!

답글 달기
comment-user-thumbnail
2022년 5월 24일

감사합니다 ~ 덕분에 시행 착오 안거치고 가네요

답글 달기