mysql> create user 'paritch'@'%' identified by 'password123!';mysql> grant all privileges on *.* to 'paritch'@'%' with grant option;
생성한 사용자로 MySQL 재접속
mysql> exit;$ sudo mysql -u paritch -pEnter password: password123!
MySQL Database 생성
mysql> create database paritch;
MySQL 외부접속 허용
// DB EC2 Uduntu 로 이동 후$ cd /etc/mysql/mysql.conf.d$ sudo vi mysqld.cnf// bind-address 를 0.0.0.0 으로 수정 후 :wq
MySQL 재시작
$ sudo service mysql restart
서버 EC2 와 DB EC2 연결
build.gradle 의존성 변경
$ cd repository/jwp-shopping-cart$ vi build.gradle// h2 의존성 제거 후 mysql 의존성 추가implementation 'mysql:mysql-connector-java'
application.properties 설정 변경
$ cd repository/jwp-shopping-cart/src/main/resources$ vi application.properties$ vi build.gradle// h2 설정 제거 후 mysql 설정 추가spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driverspring.datasource.url=jdbc:mysql://192.168.0.240:3306/paritch?serverTimezone=UTC&characterEncoding=UTF-8spring.datasource.username=paritchspring.datasource.password=password123!
프로젝트 빌드
$ cd jwp-shopping-cart$ ./gradlew bootJar
백그라운드로 프로젝트 실행
$ cd build/libs$ java -jar jwp-shopping-cart-0.0.1-SNAPSHOT.jar &