[MySQL][MacBook 설치]

·2 min read

[Terminal을 통해 brew 명령으로 설치]

{pc-name}@{pc-name}ui-MacBookPro ~ % brew install mysql ==> Downloading https://formulae.brew.sh/api/formula.jws.json ######################################################################### 100.0% ==> Downloading https://formulae.brew.sh/api/cask.jws.json ~ ... ~ ==> /opt/homebrew/Cellar/mysql/9.0.1/bin/mysqld --initialize-insecure --user=joh ==> Caveats We've installed your MySQL database without a root password. To secure it run: mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run: mysql -u root

To start mysql now and restart at login: brew services start mysql ... ~ ...  


[MySQL 실행]

{pc-name}@{pc-name}ui-MacBookPro ~ % brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
## pc 재시동해도 자동 로그인
{pc-name}@{pc-name}ui-MacBookPro ~ % mysql --version
mysql  Ver 9.0.1 for macos13.6 on arm64 (Homebrew)
{pc-name}@{pc-name}ui-MacBookPro ~ % mysql
ERROR 1045 (28000): Access denied for user 'johnnyji'@'localhost' (using password: NO)
{pc-name}@{pc-name}ui-MacBookPro ~ % mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
## 비밀번호 설정없이 설치한 상태
{pc-name}@{pc-name}ui-MacBookPro ~ % mysql -u root
## 비밀번호 입력없이 로그인
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 9.0.1 Homebrew

Copyright (c) 2000, 2024, 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, database-table 생성]

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> create database kodeJun;
Query OK, 1 row affected (0.01 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| kodeJun            |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> use kodeJun;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql>
~~~~~ ~~~~~ ~~~~~ ~~~~~ ~~~~~ ~~~~~ ~~~~~ ~~~~~ ~~~~~ ~~~~~
[MySQL workbench]

기본 세팅으로 접속 가능