memostack
article thumbnail
Published 2020. 10. 30. 22:26
MySQL 설치하기 (Mac OSX) Database/RDB
블로그를 이전하였습니다. 2023년 11월부터 https://bluemiv.tistory.com/에서 블로그를 운영하려고 합니다. 앞으로 해당 블로그의 댓글은 읽지 못할 수 도 있으니 양해바랍니다.
반응형

MySQL 설치

본 글에서는 Homebrew를 이용하여 MySQL을 설치한다.

$ brew update
$ brew install mysql

 

만약, 특정 버전을 따로 설치하고 싶다면 아래 명령어를 수행한다.

그리고, 원하는 버전의 mysql을 설치한다.

$ brew search mysql
==> Formulae
automysqlbackup            mysql-client@5.7           mysql@5.6
mysql                      mysql-connector-c++        mysql@5.7
mysql++                    mysql-sandbox              mysqltuner
mysql-client               mysql-search-replace
==> Casks
mysql-connector-python     mysql-utilities            navicat-for-mysql
mysql-shell                mysqlworkbench             sqlpro-for-mysql

 

본 글에서는 brew install mysql로 설치한다.

 

설치 확인

--version 옵션을 주어 실행하면, 현재 버전과 기타 정보들을 확인 할 수 있다.

$ mysql --version
mysql  Ver 8.0.22 for osx10.15 on x86_64 (Homebrew)

 

MySQL 서버 실행

아래 명령어로 MySQL 서버를 실행한다.

$ mysql.server start
Starting MySQL
.. SUCCESS! 

 

MySQL 설정

서버는 실행되었으나, MySQL 설정을 해줘야 DB에 접근할 수 있다.

$ mysql_secure_installation

 

설정 1. 비밀번호

  • YES: 복잡한 비밀번호
  • NO: 쉬운 비밀번호
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
Please set the password for root here.

New password: 

Re-enter new password: 

 

설정 2. 유저 사용 여부

  • YES: 접속시 -u 옵션 필요함
  • NO: 접속시 -u 옵션 필요없이 접근 가능
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
Success.

 

설정 3. 원격 접속

  • 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) : no

 ... skipping.

 

설정 4. 테스트 데이터베이스 사용 여부

  • YES: 제거
  • NO: 유지
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.

 

설정 5: 변경 내용을 테이블에 적용 여부

  • YES: 적용
  • NO: 미적용
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 접속

위에서 설정한 비밀번호로 MySQL에 접근한다.

$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.22 Homebrew

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

 

 

참고. MySQL 삭제

$ brew uninstall mydsql

 

반응형

'Database > RDB' 카테고리의 다른 글

Homebrew를 이용하여 Maria DB 설치하기 (Mac OSX)  (0) 2021.05.09
MySQL root 비밀번호 변경하기  (0) 2020.12.02
블로그를 이전하였습니다. 2023년 11월부터 https://bluemiv.tistory.com/에서 블로그를 운영하려고 합니다. 앞으로 해당 블로그의 댓글은 읽지 못할 수 도 있으니 양해바랍니다.
profile

memostack

@bluemiv_mm

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!