MAC에서 MySQL설치방법은 MySQL Community Server dmg파일을 다운받아 설치하는 방법과 Homebrew로 MySQL 패키지 다운받아 설치하는 방법 두가지이다.
1-1. MySQL Community Server 다운
1-2. 설치한다. 끝.
2-1. brew 확인 및 업데이트
> brew -v
Homebrew 2.2.13
Homebrew/homebrew-core (git revision e10a94; last commit 2020-04-17)
> brew update
2-2. MySQL 패키지 확인
> brew search mysql
==> Formulae
automysqlbackup mysql-client@5.7 mysql-search-replace
mysql ✔ mysql-connector-c++ mysql@5.6
mysql++ mysql-connector-c++@1.1 mysql@5.7
mysql-client mysql-sandbox mysqltuner
==> Casks
homebrew/cask/mysql-connector-python homebrew/cask/navicat-for-mysql
homebrew/cask/mysql-shell homebrew/cask/sqlpro-for-mysql
homebrew/cask/mysql-utilities
2-3. brew install mysql
> brew install mysql
2-4. MySQL 설치 확인
> brew list
apr gettext libidn2 nghttp2 readline
apr-util glib libmetalink oniguruma rtmpdump
argon2 gmp libpng openldap sqlite
aspell icu4c libpq openssl@1.1 tidy-html5
autoconf jansson libsodium pcre unixodbc
awscli jemalloc libssh2 phalcon@4.0.5 webp
brotli jpeg libtiff php wget
c-ares krb5 libtool php72-phalcon xz
curl-openssl libev libunistring php@7.2 zsh
freetds libevent libzip protobuf
freetype libffi mysql psr@74
gdbm libidn ncurses python@3.8
3-1. MySQL 실행
> mysql.server start
Starting MySQL
SUCCESS!
3-2. MySQL 설정
> mysql_secure_installation
mysql_secure_installation: [ERROR] unknown variable 'default-character-set=utf8'.
Securing the MySQL server deployment.
Enter password for user root:
3-1. 비밀번호 복잡성 유무
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
3-2. 비밀번호 설정
New password:
Re-enter new password:
3-3. 사용자 설정
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
3-4. 원격 접속 설정
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
3-5. TEST 데이터베이스 설정
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.
3-6. 변경된 권한을 테이블에 적용여부 설정
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
3-7. 설정 완료
All done!
4-1. local MySQL server 접속
> mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.19 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>
4-2. MySQL 서버 설정 확인
mysql> status
--------------
mysql Ver 8.0.19 for osx10.15 on x86_64 (Homebrew)
Connection id: 12
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: less
Using outfile: ''
Using delimiter: ;
Server version: 8.0.19 Homebrew
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Binary data as: Hexadecimal
Uptime: 19 min 18 sec
Threads: 3 Questions: 14 Slow queries: 0 Opens: 137 Flush tables: 3 Open tables: 59 Queries per second avg: 0.012
--------------
5-1. 설정 파일 위치 및 구성
> cat /etc/my.cnf
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
init_connect=SET collation_connection=utf8_general_ci
init_connect=SET NAMES utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
-- Global 환경변수 확인
mysql> SHOW GLOBAL VARIABLES;
mysql> SHOW GLOBAL VARIABLES\G;
-- 현재 Session 환경변수 확인
mysql> SHOW VARIABLES;
mysql> SHOW VARIABLES\G;
5-2. MySQL 시스템 변수의 특징
5-3. MySQL 서버 시스템 변수
5-4. MySQL 서버 시스템 변수 의미
5-5. 서버 시스템 변수 특성 의미