개발/DATABASE

[MariaDB] MacOS에서 MariaDB설치하기

독코더 2022. 12. 24. 18:49
반응형

맥북 유저라면 homebrew를 이용하여 간단하게 설치할 수 있습니다. 우선 터미널을 열고,

 

brew install mariadb

 

homebrew가 업데이트가 되며, 설치가 될때까지 기다려줍니다.

 

설치가 완료되었다면 실행시켜봅니다.
brew로 설치한 서비스들을 시작할때는 아래와 같은 구문을 사용합니다.

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

mariadb를 실행시켰다면 실제로 동작하는지 확인해봅시다.

 

brew services list

그럼 brew로 설치된 서비스들의 동작 여부를 확인할 수 있습니다.

rrumang@yuminhaui-MacBookPro ~ % brew services list
Name    Status  User    File
mariadb started rrumang ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist

MariaDB root 계정 생성

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

 

sudo mariadb-secure-installation

sudo를 이용해 진입하면 sudo 패스워드를 입력해야합니다.

 

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

rrumang@yuminhaui-MacBookPro ~ % 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):

MariaDB 설정이 이루어질텐데, 아래와 같이 진행하면 됩니다.

 

처음은 계정인증관련 설정이 이루어집니다. n

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'.

그다음 root 비밀번호를 바꿀거냐고 묻습니다. y를 선택하고 비밀번호를 설정해줍니다.

Change the root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

 

MariaDB는 기본적으로 익명유저를 만드는데, 익명유저를 원치않으면 y를 입력합니다.

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!

 

localhost에서만 root로 접속할 수 있는지, 아니면 외부에서도 root로 접속할 수 있게할지 선택합니다.

원격에서 root계정으로 접속이 가능하게 하려면 n을 입력합니다.

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.

 

테스트 데이터베이스를 삭제하고 싶다면 y를 입력합니다.

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!

 

y를 눌러 리로드해줍니다.

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 root 계정에 접속

mysql -u root -p

위 내용을 작성하고 설정해준 패스워드를 쳐주면 mariadb 접속 성공입니다.

반응형