MySQL 프로젝트 초기설정
MySQL 연결
Section titled “MySQL 연결”- MySQL 초기 설정은 도커 컨테이너에 접속해서 명령어를 입력해야 한다.
- MySQL 컨테이너의 bash 실행
Terminal window docker-compose exec mysql bash$ docker-compose exec mysql bashbash-5.1# - 관리자 권한으로 접속
Terminal window mysql -u root -p mysqlbash-5.1# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 20Server version: 9.5.0 MySQL Community Server - GPLCopyright (c) 2000, 2025, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> - 연결 테스트
Terminal window show databases;mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.001 sec)
MySQL 데이터베이스 및 사용자 생성
Section titled “MySQL 데이터베이스 및 사용자 생성”- Database 생성
text create database ${DATABASE_NAME};
- 사용자 생성
create user '${USER_NAME}'@'%' identified by '${PASSWORD}';
- 사용자 조회
select * from user where user = '${USER_NAME}';
- 권한 설정
privileges on ${DATABASE_NAME}.* to '${USER_NAME}'@'%' with grant option;
- 모니터링 권한 설정
grant process on *.* to ${USER_NAME}; grant select onperformance_schema.* to ${USER_NAME}; grant show databases on *.* to ${USER_NAME};
- 설정내역 디스크에 저장
flush privileges;
데이터베이스 활용
Section titled “데이터베이스 활용”- 외부에서 데이터베이스 작업을 수행한다.
- 테이블 및 데이터 생성
- 인덱스 생성
- 데이터베이스를 사용하는 애플리케이션 개발이 가능하다.
- 웹 애플리케이션 개발
- 모바일 애플리케이션 개발