(MAC) MySQL 설치하기

hwwwa·2022년 1월 8일
post-thumbnail

설치

Homebrew를 이용해 MySQL 설치

  • homebrew 설치 → https://brew.sh/index_ko
  • homebrew를 이용해 mysql을 설치하는 게 가장 간단하고 관리하기 편함
  • 터미널을 켜고 아래의 명령어를 입력
brew install mysql
  • 설치 완료 후 mysql의 버전 확인
mysql -V

mysql Ver 8.0.27 for macos12.0 on x86_64 (Homebrew)

서버 켜기

mysql.server start

설정

  • MySQL 서버가 정상적으로 시작되었다면 아래 명령어를 통해 초기 설정
mysql_secure_installation

비밀번호 복잡성 유무 선택:

  • 복잡한 비밀번호를 하려면 Yes, 아니라면 No
  • 그 후 사용할 비밀번호를 설정
inhwa-MacBookPro:~ hwwwa$ mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No:  No

익명 유저

  • MySQL에는 기본 설정으로 익명 유저를 만듦. 제거를 원한다면 Yes 입력
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) :  Yes

root 접속 권한

  • localhost에서만 root로 접속할 수 있는지, 아니면 외부에서도 root로 접속 가능하게 할 지 선택
  • 원격 접속을 불가능하게 하려면 Yes, 아니면 No
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? (Press y|Y for Yes, any other key for No) :

test database 삭제 유무

  • Yes 입력 시 test database를 모두 삭제
By default, MySQL 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? (Press y|Y for Yes, any other key for No) : yes     
 - 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.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : yes
Success.

All done!
  • 초기설정이 완료 됨. 언제든지 명령어를 사용해 다시 설정 가능

접속

mysql -u root -p

  • exit를 입력하면 mysql 종료 가능
mysql> exit
Bye

서버종료

mysql.server stop

0개의 댓글