mac m1 에 mysql 을 설치합니다.
터미널을 실행시킨 다음, 아래의 명령어를 입력합니다.
brew install mysql
- 해당 명령어를 입력하면 쭉 설치되는 과정이 출력되고 좀 기다리면 설치가 완료됩니다.
설치 후, 설치된 mysql 버전을 확인합니다.
mysql -V
- 현재 mysql 8.0.33이 설치된 것을 확인할 수 있습니다.
Mysql 실행
mysql.server start
해당 명령어를 입력하고 SUCCESS! 가 뜬다면 잘 실행이 된 것입니다.
반대로 mysql 실행 중지를 하고 싶다면 아래와 같이 명령어를 입력해주면 됩니다.
mysql.server stop
Mysql 설정
mysql_secure_installation
- 해당 명령어를 입력하면 기본 설정을 할 수 있습니다.
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: N
비밀번호를 복잡하게 만들것이냐고 묻는 질문인데 간단하게 정할 것이기 때문에 N을 입력했습니다. 복잡하게 정하기 위해서는 y 또는 Y를 입력해주면 됩니다.
해당 질문을 대답하면 비밀번호를 설정할 수 있습니다.
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) : y
비밀번호 설정 후 기본적으로 만들어지는 익명유저를 삭제할 것이냐고 물어보는 질문입니다. y를 입력해주었습니다.
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) : y
원격으로 로그인하는 것을 막을 것이냐라는 질문이고 저는 제 로컬에서만 사용할 것이기 때문에 y로 설정하였습니다.
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) : N
테스트용 database를 지울 것이냐는 질문으로 저는 사용할 것이라서 N을 입력해주었습니다.
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) : y
설정내용을 테이블에 적용할 것인지 묻는 질문으로 y를 입력해줍니다.
설정을 다시해야 한다면 언제든 똑같이 mysql_secure_installation 이 명령어를 입력해주고 설정해주면 됩니다.
Mysql 접속하기
mysql 에 접속하기 위해서 mysql -u root -p 를 입력해서 아까 설정했던 비밀번호를 입력하고 접속합니다.
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.33 Homebrew
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
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>
1. 데이터베이스 확인
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql>
2. 데이터베이스 선택
mysql> use sys
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
3. 선택한 데이터베이스에 존재하는 테이블 확인하기
mysql> show tables;
+-----------------------------------------------+
| Tables_in_sys |
+-----------------------------------------------+
| host_summary |
| host_summary_by_file_io |
| host_summary_by_file_io_type |
| host_summary_by_stages |
| host_summary_by_statement_latency |
4. mysql 종료하기
mysql> exit
Bye
DBeaver로 mysql 접속하기
새 데이터베이스 연결 버튼을 클릭하면 다음과 같은 화면이 나옵니다.
mysql 선택 후 다음을 클릭합니다.
- Server Host : localhost
- Database : 선택하고 싶은 데이터베이스
- Password : 초기에 설정 시 입력했던 root계정 비밀번호
Test Connection ... 버튼을 클릭하면 다음과 같이 잘 연결된다는 메세지가 떠야합니다.
그 다음 완료 버튼을 누르게되면 DBeaver에서 해당 데이터베이스를 사용할 수 있게 됩니다.
'Database' 카테고리의 다른 글
[Redis] Mac M1 에서 redis(레디스) 설치하기 (0) | 2023.11.03 |
---|---|
[Database] H2 Database mac 설치 방법 & h2 데이터베이스 연결 안되는 에러 해결 (0) | 2023.03.05 |