Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring JPA MySQL 연동 #52

Closed
yanghun0070 opened this issue Dec 20, 2020 · 2 comments · Fixed by #54
Closed

Spring JPA MySQL 연동 #52

yanghun0070 opened this issue Dec 20, 2020 · 2 comments · Fixed by #54

Comments

@yanghun0070
Copy link
Owner

  • Spring JPA MySQL 연동
  • 로컬 시에는 Docker MySQL 추가하여 테스트 진행
@yanghun0070
Copy link
Owner Author

yanghun0070 commented Feb 6, 2021

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

@yanghun0070
Copy link
Owner Author

yanghun0070 commented Mar 7, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant