Closed yanghun0070 closed 3 years ago
docker pull mysql
docker run --name dayco-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -v /Users/yanghun007/dayco/mysql:/var/lib/mysql -e MYSQL_USER=daycouser -e MYSQL_PASSWORD=daycouser mysql
docker exec -it dayco-mysql /bin/bash
mysql -u root -p
use mysql
select host, user, authentication_string from user;
create user daycouser;
create user daycouser@localhost identified by 'daycouser';
create user 'daycouser'@'%' identified by 'daycouser'; // '%' 의 의미는 외부에서의 접근을 허용
drop user 'daycouser'@'localhost'; // 계정 삭제
show databases;
create schema daycodb default character set utf8;
drop database daycodb;
grant all privileges on daycodb.* to 'daycouser'@localhost identified by 'daycouser';
grant select, insert, update on daycodb.* to 'daycouser'@localhost identified by 'daycouser';
grant select, insert, update on daycodb.* to 'daycouser'@'%' identified by 'daycouser';
//user 에게 uaadb 데이터베이스 모든 테이블에 select, insert, update 권한 부여
grant select, insert, update on daycodb.* to 'daycouser'@localhost; // 패스워드는 변경없이 권한만 부여하는 경우
mysql> grant all privileges on *.* to 'daycouser'@'%' with grant option;
flush privileges; // 변경된 내용을 메모리에 반영(권한 적용)
revoke all on daycodb.* from daycouser; // 모든 권한을 삭제
docker inspect dayco-mysql
build.gradle
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.15'
application.yml
spring:
jpa:
show-sql: true
properties:
hibernate:
format_sql: true
database: mysql
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
generate-ddl: true
application:
name: dayco-uaa
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/uaadb?useSSL=false
username: uaauser
password: uaauser