728x90

참고문서

[RN] React-Native 시작하기

medium.com/@jang.wangsu/rn-react-native-%EC%8B%9C%EC%9E%91-3aab881f574f

Introduction

reactnative.dev/docs/getting-started

 

1. React-Native 시작하기 전

Homebrew 설치하기

brew.sh/index_ko

 

Homebrew

The Missing Package Manager for macOS (or Linux).

brew.sh

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

 

npm 을 사용하기 위해 node 설치

$ brew update
$ brew uninstall node
$ brew install node
$ brew postinstall

 

npm 설치확인

$ npm --version

 

 

 

 

Yarn 설치하기

$ npm install --global yarn


/usr/local/bin/yarn -> /usr/local/lib/node_modules/yarn/bin/yarn.js
/usr/local/bin/yarnpkg -> /usr/local/lib/node_modules/yarn/bin/yarn.js
+ yarn@1.22.4

 

 

2. React-Native 를 위한 2가지 방법

샘플 앱 실행을 위해서는 크게 2가지가 존재합니다.

 

1. CRNA (Create-react-native-app)를 이용하는 방법

Xcode나 android studio를 설치할 필요가 없는 방식으로 바로 실행해 보길 원하는 경우에 이용합니다.

이때 Expo 를 이용하면, android studio, Xcode 가 필요없이 개발 진행을 도와주고, Expo Clint로 테스트도 가능합니다.

 

2. React-native 명령어를 이용하는 방법
이전 react native를 사용하는 보통의 개발 방법입니다.
CRNA가 2017년 나왔으며 앞으로는 CRNA를 권장할 가능성이 있습니다.
react-native 명령어를 이용하는 방법은 iOS 개발을 위해 Mac이 꼭 필요합니다.

 

 

2-1. CRNA (Create-react-native-app)를 이용하는 경우, 설치

-- CRNA 설치

$ npm install -g create-react-native-app

-- 프로젝트를 생성합니다.

$ create-react-native-app 프로젝트명
$ cd 프로젝트 명
$ npm start

 

먄약 실행이 안된다면

Androi인 경우는 USB에 안드로이드 폰을 연결하세요.
https://developer.android.com/studio/run/device.html#developer-device-options
그리고 실행후에는 안드로이드 폰은 노트북과 같은 Wi-Fi에 같이 존재해야 합니다.

 

 

노드는 설치가 되어 있다면 아래  watchman 설치, 자세한 설명은 프로젝트 Readme.md에 나와있습니다.

$ brew install watchman
6. Readme.md 파일 확인

 

 

2-2. React-native 명령어를 이용하는 방법

-- react-native-cli 설치

$ npm install -g react-native-cli

-- react-native 를 설치하진 마세요.

$ react-native init 프로젝트명
$ cd 프로젝트명

$ react-native run-ios
또는 
$ react-native run-android

* npm install -g react-native  을 설치하지 마세요.

 

Error 발생시

처음에 언급한 getting-started Site에서 빠진 부분이 없는지 확인해야 됩니다.

 

iOS : Xcode -> Preferences -> Locations -> Command Line Tools 의 설정이 빠져있다면 설정해주세요.

Android: JDK 설치 유무확인, SDK Manager에서 필수 설치 미설치 여부 인해야 합니다.

 

테스트 버전정보

$ brew --version
Homebrew 2.4.2
Homebrew/homebrew-core (git revision 94f44; last commit 2020-06-30)

$ react-native --version
react-native-cli: 2.0.1
react-native: 0.62.2

$ yarn --version
1.22.4

$ create-react-native-app --version
3.5.0

$ node --version
v14.4.0

$ npm --version
6.14.4

 

728x90

 

Android 개발 가이드 / Android 개발 가이드라인 / Android 코딩 스타일 가이드

http://developer.gaeasoft.co.kr/development-guide/android-guide/android-coding-style-guide/

 

Follow Field Naming Conventions

가. Non-public, non-static field 는 m으로 시작

예) 
private int mPrivate;

int mPackagePrivate;

protected int mProtected;

 

 

나. Static field 는 s로 시작

예) private static MyClass sSingleton;

 

다. 나머지는 소문자로 시작.

 예) public int publicField;

 

라. Public static final fields (상수) 는 모두 대문자로 ALL_CAPS_WITH_UNDERSCORES.

예) public static final int SOME_CONSTANT = 42;

 

public class MyClass {

	public static final int SOME_CONSTANT = 42;

	public int publicField;

	private static MyClass sSingleton;

	int mPackagePrivate;

	private int mPrivate;

	protected int mProtected;

}

 

시작 중괄호는 "{" 따로 한줄을 차지하지 않는다.

class MyClass {

	int func() {

		if (something) {

			// ...

		} else if (somethingElse) {

			// ...

		} else {

			// ...

		}
	}
}

 

if (condition) body();

 

TODO 주석문 또는 FIXME 주석문을 사용 할 것.

단기처방이나, 완벽하지 않은 해결책인 경우에는 반드시 TODO or FIXME주석문을 기입할 것.

// TODO: UrlTable2

또는

// FIXME: flag

 


Activity 개발 시 주의 사항

context를 별도 멤버로 선언하고 관리하지 않도록 하자.

context가 필요하면 getContext() 를 사용하자.

 

잘못된 사례

아래 예시는 잘못된 예시입니다.

public class MyActivity extends Activity {

	private Context mContext = null;

	...

	...

	protected void onCreated(Bundle savedInstanceState){

	mContext = this;

}

 


JavaTests Style Rules

테스트 방법 명명 규칙 준수

Test Method 의 이름을 설계할 때, test case를 "_" 뒤에 붙여줄 수 있다.

예)

testMethod_specificCase1 testMethod_specificCase2

void testIsDistinguishable_protanopia() {
 ColorMatcher colorMatcher = new ColorMatcher(PROTANOPIA)
 assertFalse(colorMatcher.isDistinguishable(Color.RED, Color.BLACK))
 assertTrue(colorMatcher.isDistinguishable(Color.X, Color.Y))
}

 


로깅(Log)은 간결하게.

로깅은 성능에 지대한 영향을 준다.

로깅하기 전에 먼저, 로그 레벨을 이해하자.

 

ERROR 레벨: 항상 기록되는 레벨, 뭔가 치명적인 상황을 기록한다.

따라서 조심스럽게 사용해야 한다. 먼가 치명적인 상황을 기록한다.

예를 들어 어떤 데이터를 직접 삭제하거나, 앱을 지우거나, 폰을 싹 밀어버리거나 하기 전에는 복구가 안되는 상황을 사용자가 직면해야 할때만 기록하고, (가능하면)통계수집 서버에 통보하도록 하자.

 

WARNING 레벨: 항상 기록되는 레벨, 심각한 상황을 기록한다.

심각한 상황을 기록한다.

예를 들어 사용자가 인식할 수 있는 오류결과가 나타나고, 사용하던 데이터(다운로드 중인 데이터 등등)가 날아가버리고,

사용자가 앱 혹은 폰을 리부팅하거나, 화면을 죽이거나, 새로운 버전의 앱을 다운 받기 전에는 복구가 안되는 상황에 사용하자.

 

0 INFORMATIVE: 역시 항상 기록되는 레벨, 오류가 아닌 뭔가 대단한 상황일 경우 기록한다.

오류는 아니더라고, 뭔가 모두가 알았으면 하는 대단한 상황일 경우 기록한다.

예를 들어 오류는 아니지만, 동접자 수가 100만명이 넘어갔다거나, 악성코드로 의심되는 입력값이 감지되었다거나 등등 모두가 알면 좋을 만한 사건이 발생한 상황에 사용하자.

 

DEBUG 레벨: 디버그 모드에서만 기록되는 레벨, 디버깅 과정과 관련된 추가 정보를 기록한다.

디버깅 과정과 관련한 추가 정보를 기록할 때 사용한다.

만약 로깅 자체보다는 개발자 본인의 관심사와 관련한 정보라면 verbose level로 로깅하자.

 

배포 버전에도 로깅이 가능하며, 로깅과 관련한 소스가 컴파일 되기 때문에 성능을 고려한다면

로깅 소스는 반드시 다음과 같이 if (LOCAL_LOG) or if (LOCAL_LOGD) 구문내에 구현해야 한다.

 

혹시나, 다른 대안으로 리펙토링을 통해 logging 기능을 밖으로 빼는 방법을 생각해보기도 하는데 (re-factoring out), 이는 좋은 생각이 아니다.

왜냐하면, String 파라미터가 전달되면서 불필요한 String 생성이 발생하기 때문이다.

 

VERBOSE 레벨: 뭐든 로깅해도 되는 레벨, 개발자 본인의 관심사와 관련된 정보 등을 기록한다.

debug level 처럼 반드시 if구문내에 구현하도록 하자.

아니면 배포전에 아예 없애버리자.

 


기억할 것

1. VERBOSE 레벨 이 아닐경우 - 상위 method 오버로딩 시 상위 method에 logging하자.

하나의 모듈 내에 있는 하나의 function chain 내에서 오류는 가능한 한번만 보고(logging)가 되도록 해야 한다.

이를테면 method overloading 방식으로 methodA(param1) 가 methodA(param1, param2)를 호출하면 error는 methodA(param1, param2) 에서만 기록하도록 하자.

그래야 issue를 격리시키는 게 쉬워진다.

 

2. VERBOSE 레벨 이 아닐경우 2 - 상위 모듈에 전달된 DATA 가 문제가 될 경우, debug모드로 

연쇄적으로 작동하는 모듈간에 만약 상위 모듈에서 전달된 data에 문제가 있다고 판단될 경우 로깅을 하려면 debug 모드로 해야 한다.

굳이 information 이상 레벨의 로깅이 필요하다면, 상위 레벨 모듈에서 처리해야한다.

특히 lib 나 프레임워크개발시에 이런 규칙이 중요하다.

lib 나 framework를 가져다 쓰는 경우 마음대로 로깅을 남기고 곤란한 경우가 발생한다.

 

3. 반복되거나 동일한 작업이 예상되는 것은 일정한 조건을 걸어서 로깅해라.

이를 테면, onTouchEvent 내에 로깅할때 네트웍 단절 상태등은 충분히 예상되는 내용이다. debug verbose 이상의 로깅을 하지 말자.

 

 

4. 다른 앱에서 접근가능한 파일시스템 용량 초과 같은 이슈는 INFORMATIVE 이하 레벨로 검증 되지 않은 소스로부터 들어오는 잘못된 데이터 입력등의 이슈는 DEBUG 이하로 작성할 것.

 

5. Log.v() 는 배포버전에서도 컴파일 된다.

레벨에 따라 로깅이 안될 뿐이지. 따라서 반드시 if 구문안에서 String을 처리해야함.

 

 

6. 모든 로깅은 간결하고 누구나 쉽게 이해할 수 있어야 한다.

작성자만 알아볼 수 있게 하지 말 것. (DEBUG level 이상의 로깅이라면 말이지)

 

7. 가능한 한줄로 표현되게끔 해주세요. 너무 길지도 않게.

 

8. 작업 성공 여부 같은 것은 VERBOSE 외에선 사용하지 말 것.

 

9. 검사나 분석을 위한 임시 로깅은 반드시 DEBUG or VERBOSE level 에서만 작성할 것.

 

10. 로깅으로 개인정보 등 보안 정보가 유출되지 않도록 각별히 신경 쓸것.

 

11. System.out.println()(or printf() for native code) 는 절대 사용하지 말것.

System.out와 System.err는 /dev/null 로 연결되므로 아무 기능도 안하게 되는데 괜히 StringBuilder 만 잡아 먹게 된다.

 

12. 로그가 로그를 만들게 하지 말자.

 

 

 

728x90

하나의 예시일뿐이며 해당 내용에 대한 작업 플로우는 아래 참고URL이 있으니 확인해 보시길 바랍니다.

Git을 사용하기 위한 세팅을 마친 "A책임"와 "B선임"는 서로 나뉘어서 코딩을 하기로 했습니다.

1. 20XX년 04월 01일, "A책임"과 "B선임"이 각각 브랜치를 땁니다.

"A책임"는 "main 페이지"를 만들기 위해 ‘feature/A-source’이란 이름으로, "B선임"는 "register 페이지"를 만들기 위해 ‘feature/B-source’ 이란 이름으로 "orgin/prod" 브랜치의 최신 커밋으로부터 새로운 브랜치를 만들었습니다.

   * 브랜치 앞에 ‘feature/‘처럼 슬래시로 구분된 이름을 달아주면 이 구분별로 브랜치를 묶어볼 수 있는 장점이 있습니다.


2. "A책임"와 "B선임"은 각자 브랜치에서 코딩을 합니다.

3. 20XX년 04월 05일 - A책임 : ‘feature/A-source’ 1차 작업 완료, "Pull Request"

   시간이 흘러 "A책임"이 main 페이지를 다 만들어 "orgin/dev" 에 ‘feature/A-source’ 브랜치를 merge 할려고 합니다.
   하지만 "예고 없이" 바로 합치기 보다는 "B선임"에게 리뷰를 먼저 받고 합치고 싶습니다.
   * 그러기 위해서 사용하는 것이 "Pull Request" 입니다. (git의 기능이 아니고 github에서 제공하는 기능입니다.)

 

4. 20XX년 04월 05일 - A책임 : "Pull Request" 버튼을 눌러 ‘feature/A-source’에서 "orgin/dev" 브랜치로 Pull Request(땡김 요청)

   "Github저장소"에 있는 "Pull Request" 버튼을 눌러 ‘feature/A-source’에서 "orgin/dev" 브랜치로 Pull Request(땡김 요청)를 보냅니다.
   * 즉, "feature/A-source"에 소스를 수정해놨으니 "orgin/dev" 브랜치에서 땡겨가라고 요청하는 것입니다.

 

5. 20XX년 04월 05일 - 배포담당자 : "Pull Requests"로 요청한 내용 확인 후 "Merge pull request"로 "orgin/dev"에 merge

그럼 GitHub저장소의 ‘Pull requests’섹션에서 "A책임"이 보낸 "Pull Request" 를 확인할 수 있습니다.
Files changed를 보고 잘 만들었는지 여부를 확인하고, 잘 되었다면 ‘Merge pull request’를 눌러 "A책임"의 커밋들을 "orgin/dev" 브랜치에 합칩니다. 원하는게 아니라고 생각되면 거부할 수도 있습니다.

 

6. 20XX년 04월 06일 - B선임 : 작업마치고 "Pull Request" 할려니 Merge Conflicts (소스 충돌) 우려 발생

그 와중에 "B선임"도 "register 페이지" 작업을 마치고 "orgin/dev" 브랜치에 "Pull Request"를 보내려 보니 "A책임"의 새로운 코드가 추가(20XX년 04월 05일)되어 "이책임"이 처음에 땄던 "orgin/dev" 커밋(20XX년 04월 01일)와 상태가 달라졌습니다.

   * "B선임"이 만든 소스는 'orgin/dev'에서 2020년 04월 01일에 브랜치를 땄기 때문에 옛날 버전이 되었습니다.
   * "A책임"이 2020년 04월 05일 'orgin/dev'에 소스를 추가하였기 때문입니다.

 

7. 20XX년 04월 06일 - B선임 : 'orgin/dev'의 소스를 자신의 "feature/B-source" 에 merge

"B선임"은 ‘선-merge 후-pull request’를 보냈습니다.
자신의 local 'feature/B-source'에 'orgin/dev'의 최신 커밋을 마우스 오른쪽 버튼을 눌러 Merge하였습니다.
그랬더니 Merge Conflicts(Merge 충돌) 이 났습니다.

 

8. 2020년 04월 06일 - B선임 : Merge Conflicts(Merge 충돌)해결

   "A책임"와 "B선임" 둘 다 같은 소스를 고치다 보니 충돌이 났습니다.
   코드를 보니 "B선임"의 코드가 맞다고 합니다.
   수동으로 "A책임"의 코드를 지우고 "B선임"의 코드를 남겨 commit+push 합니다.
   * marge compare 를 통해서 해당 부분을 체크해서 merge 처리 합니다.

 

9. 2020년 04월 06일 - 이제 "B선임"도 "orgin/dev"로 "Pull request"를 보내고 배포관리자는 merge합니다.

"A책임"이 확인하고 "merge"하니 오류가 없습니다.
"이책임"의 "feature/B-source"에는 "orgin/dev"의 코드도 잘 섞여있는 버전이 들어가 있기 때문입니다.

 

10. 이제 "orgin/dev"에 "A책임"의 "main 페이지" 와 "B책임"의 ‘"register 페이지"가 모두 반영되었습니다.

 

11. 배포를 위해 "orgin/dev"에서 "orgin/master" 브랜치로 "pull request"를 보내고 "배포관리자"는 merge 합니다.

 

참조 : 
https://medium.com/@psychet_learn/git-%EC%82%AC%EC%9A%A9%EB%B2%95-3%EC%9E%A5-github-%EC%9D%B4%EC%9A%A9%ED%95%98%EA%B8%B0-f53e765844e3
참조 : 
https://milooy.wordpress.com/2017/06/21/working-together-with-github-tutorial/

 

728x90

http://blog.naver.com/PostView.nhn?blogId=stork838&logNo=220142660973&parentCategoryNo=&categoryNo=37&viewDate=&isShowPopularPosts=true&from=search

 

멀티파트파일을 java.io.File로 변환하기 ( converting MultipartFile to File )

스프링에서 제공하는 멀티파트파일객체를 자바의 파일객체로 변환하는 방법을 소개한다.public File conve...

blog.naver.com

 

https://cnpnote.tistory.com/entry/SPRING-%EB%A9%80%ED%8B%B0-%ED%8C%8C%ED%8A%B8-%ED%8C%8C%EC%9D%BC%EC%9D%84-%ED%8C%8C%EC%9D%BC%EB%A1%9C-%EB%B3%80%ED%99%98%ED%95%98%EB%8A%94-%EB%B0%A9%EB%B2%95

 

[SPRING] 멀티 파트 파일을 파일로 변환하는 방법?

멀티 파트 파일을 파일로 변환하는 방법? 다중 파트 파일 (org.springframework.web.multipart.MultipartFile)을 File (java.io.File)로 변환하는 가장 좋은 방법은 무엇입니까? 내 봄 mvc 웹 프로젝트에서 나는 M..

cnpnote.tistory.com

 

public File convert(MultipartFile file)
{    
    File convFile = new File(file.getOriginalFilename());
    convFile.createNewFile(); 
    FileOutputStream fos = new FileOutputStream(convFile); 
    fos.write(file.getBytes());
    fos.close(); 
    return convFile;
}
public File multipartToFile(MultipartFile multipart) throws IllegalStateException, IOException 
{
    File convFile = new File( multipart.getOriginalFilename());
    multipart.transferTo(convFile);
    return convFile;
}

 

스프링에서 제공하는 multipartFile을 자바의 파일 객체 File로 변환하기 / transferTo / createNewFile() / FileOutputStream

728x90

YouTube API에서  썸네일을 업로드할려고 하는데 자꾸 forbidden 에러가 뜹니다.

처음에는 인증이 잘못되어서 그런 것인줄 알았는데 순전히 퍼미션 에러 였습니다.

그래서 퍼미션 권한을 부여해주니 에러없이 업로드 가 되었습니다.

 

"맞춤 동영상 미리보기 이미지 만들기"는 해당 계정에서 이를 확인해줬거나 실시간 스트리밍 액세스 권한이 있는 경우에만 동영상 업로드를 위한 "맞춤 미리보기 이미지"를 업로드 할 수 있습니다.

 

The authenticated user doesnt have permissions to upload and set custom video thumbnails.

"인증 된 사용자에게는 맞춤 동영상 미리보기 이미지를 업로드하고 설정할 수있는 권한이 없습니다"

 

You chose 비디오아이디 to upload a thumbnail.
Video files from /Users/jaehonghan/dev/youtubeUploadFiles:
 0 = 20200402.png
Choose the number of the video file you want to upload: 0
You chose /Users/jaehonghan/dev/youtubeUploadFiles/20200402.png to upload.
Initiation Started
Initiation Completed
GoogleJsonResponseException code: 403 : The authenticated user doesnt have permissions to upload and set custom video thumbnails.
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
  "code" : 403,
  "errors" : [ {
    "domain" : "youtube.thumbnail",
    "location" : "Authorization",
    "locationType" : "header",
    "message" : "The authenticated user doesnt have permissions to upload and set custom video thumbnails.",
    "reason" : "forbidden"
  } ],
  "message" : "The authenticated user doesnt have permissions to upload and set custom video thumbnails."
}
	at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:150)
	at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
	at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:432)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
	at com.tubro.youtube.thumbnails.test.ThumbnailsSetTest.main(ThumbnailsSetTest.java:124)

Process finished with exit code 0

 

아래에 접속하셔서 업로드하고자 하는 계정에 대해서 권한을 부여해 주세요 !!

https://www.youtube.com/verify

 

 

Contiune  버튼을 클릭하시면 해당 계정에 대한 퍼미션 인증에 대한 것들이 뜨게 됩니다.

아래 이미지에서 Custom thumbnails  가 Enabled가 뜨는 것을 확인할 수 있습니다.

 

 

만약에 아래와 같은 화면이 뜨지 않더라도 당황하지 마시고 퍼미션을 얻기 위해 버튼을 클릭해 주세요.

저 같은 경우에도 휴대폰이나 이메일 주소 인증을 통해서 실제 해당 계정에 대한 권한을 갖기 위한 확인 절차를 거쳤습니다.

휴대폰번호를 입력하고 나니 직접 구글에서 연락이 오더라구요. 

영어로 막 얘기를 하는데 ARS이니 그냥 듣고 계시다가 6자리 확인 숫자를 불러주니 그걸 잘 들으시고 입력해 주시면 됩니다.

(한국어가 아닌 영어이니 원,투,쓰리 로 말하니 잘 들으세요 ..ㅋㅋㅋ)

 

 

인증을 거치고 나서 퍼미션 권한을 획득 하시고 나서 다시 실행 해보세요.

Thumbnail이 제대로 올라가는 것을 확인하실 수 있을 것입니다.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/jaehonghan/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jaehonghan/.m2/repository/org/slf4j/slf4j-log4j12/1.7.30/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

You chose "비디오아이디" to upload a thumbnail.
Video files from /Users/jaehonghan/dev/youtubeUploadFiles:
 0 = 20200402.png
Choose the number of the video file you want to upload: 0
You chose /Users/jaehonghan/dev/youtubeUploadFiles/20200402.png to upload.
Initiation Started
Initiation Completed
Upload Completed!

================== Uploaded Thumbnail ==================

  - Url: https://i.ytimg.com/vi/비디오아이디/default.jpg

Process finished with exit code 0

 

 

728x90

mysql 8.x user 생성 및 변경, 삭제 처리 하기

 

> mysql 에 접속하시고 user 테이블로 이동 하셔서 

insert into user (Host,User,authentication_string,ssl_cipher,x509_issuer,x509_subject) values ('localhost','유저명', '', '','','');

 

insert into user (Host,User,authentication_string,ssl_cipher,x509_issuer,x509_subject) values ('localhost','유저명', '', '','','');

 

위와 같이 MySQL5.X버전의 경우와 같은 SQL문으로 user를 생성하지마세요.

 

유저가 생성되지 않습니다.

 

 

그럼 mysql에 user를 만들어 비밀번호를 반영하여 접속하는 방법을 설명하겠습니다.

먼저 MySQL에 root로 접속하신 후 mysql DB 이동해 주세요. 


0. MySQL에 root로 접속하여 mysql DB 로 이동해 주세요.

use mysql;

 

1. 사용자 정보 조회를 먼저 조회하세요.

SELECT user,authentication_string,plugin,host FROM mysql.user; 

SELECT user,authentication_string,plugin,host FROM mysql.user; 

그러면 위와 같이 뜨게 됩니다.

단, plugin 부분이 "caching_sha2_password" 로 되어서 암호화된 비밀번호의 형태가 다를 수 있습니다.

위의 경우에는 제가 "mysql_native_password" 로 변경한 것이기 때문입니다.

 

여전히 MySQL 클라이언트에서는 "caching_sha2_password" 플러그인이 반영되지 않아서 connect 가 안되기에 기존에 사용하던 "mysql_native_password" 로 변경하였기 때문입니다.

이 부분에 대해서는 아래에 변경하는 방법을 적어놨습니다.

 

2. 사용자 생성를 생성합니다.
create user '유저명'@'localhost' identified by '비밀번호'; 

create user '유저명'@'localhost' identified by '비밀번호'; 

 

3. 생성된 사용자를 확인합니다.
SELECT user,authentication_string,plugin,host FROM mysql.user; 

SELECT user,authentication_string,plugin,host FROM mysql.user; 

 

4. 생성된 사용자의 권한을 적용시켜 줍니다.
GRANT ALL PRIVILEGES ON *.* TO '유저명'@'localhost'; 
GRANT GRANT OPTION ON *.* TO '유저명'@'localhost'; 

GRANT ALL PRIVILEGES ON *.* TO '유저명'@'localhost'; 
GRANT GRANT OPTION ON *.* TO '유저명'@'localhost'; 

 

5. MySQL에 실시간 반영시켜 줍니다.
flush privileges;

flush privileges;

 

 

참고. MySQL에서 caching_sha2_password 을 mysql_native_password으로 플러그인을 변경하기

ALTER user '유저명'@'localhost' IDENTIFIED WITH mysql_native_password by '비밀번호';

ALTER user '유저명'@'localhost' IDENTIFIED WITH mysql_native_password by '비밀번호';

여전히 MySQL 클라이언트에서는 "caching_sha2_password" 플러그인이 반영되지 않아서 connect 가 안되기에 기존에 사용하던 "mysql_native_password" 로 변경하였기 때문입니다.

 


6. 사용자를 삭제할 수 있습니다.
drop user 유저명@localhost;

drop user 유저명@localhost;
flush privileges;

삭제하고 나면 꼭 "flush privileges;" 를 해주세요. MySQL에 제대로 반영을 시켜줘야 합니다.

그렇지 않으면 메모리상에 USER 정보가 남아 있어 동일한 "유저명" 으로 재생성할 수 없습니다.

예를 들어 아래와 같이 SQL문중 delete 문으로 유저를 삭제하고서 다시 동일한 유저를 생성하게 되면 에러가 뜨게 됩니다.

ERROR 1396 (HY000): Operation  관련 에러가 뜨게 됩니다.

mysql> delete from user where User='유저명';

Query OK, 1 row affected (0.00 sec)



mysql> create user '유저명'@'localhost' identified by '비밀번호'; 

ERROR 1396 (HY000): Operation CREATE USER failed for '유저명'@'localhost'

mysql> delete from user where User='유저명';

Query OK, 1 row affected (0.00 sec)

 

mysql> create user '유저명'@'localhost' identified by '비밀번호'; 

ERROR 1396 (HY000): Operation CREATE USER failed for '유저명'@'localhost'

 

아래는 실제 에러가 떠서 "Drop User " 명령문으로 삭제하고 CREATE USER 명령문으로 재 생성한 화면입니다.

728x90

Homebrew 설치하기

macOS에는 macOS 용 패키지 관리자 Homebrew가 있습니다.

Homebrew를 이용하면 설정 과정이 단순하고, 환경변수 설정이 필요없고, 관리하기 편리하기 때문입니다.

 

터미널에 아래의 명령어 입력하여 Homebrew 를 설치합니다.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

 

"Press RETURN to continue or any other key to abort" 라는 문장이 뜨면, 엔터키(리턴키)를 눌러준다.

password에는 mac의 비밀번호를 입력해 주면 됩니다.

비밀번호를 입력하지 않으면 비밀번호 없이 설치가 됩니다.

 

아래의 명령어로 cask 패키지(Safari, Chrome, Word 등과 같이 그래픽을 통해 작업하는 프로그램을 설치할 수 있게 해주는 패키지)를 설치해 줍니다.

brew install cask

 

 

Homebrew를 통해 프로그램을 설치하기 전엔 항상 아래의 명령어로 업데이트가 있는지 확인 후 진행합니다.

brew update

 

MySQL 설치

1. brew update를 통해 최신 버전으로 업데이트를 해줍니다.

2. brew search mysql을 통해 설치할 MySQL 버전을 확인해 줍니다.

3. brew install mysql을 통해 원하는 버전의 MySQL을 설치해 줍니다. (이 경우 최신버전)

// 최신 버전으로 업데이트를 해줍니다.
brew update

// 설치할 MySQL 버전을 확인해 줍니다.
brew search mysql

// 원하는 버전의 MySQL을 설치해 줍니다. (이 경우 최신버전)
brew install mysql

 

 

mysql 설치할 버전을 찾아줍니다.

 

 

$ brew search mysql

mysql 서버를 설치합니다.

$ brew install mysql

 

Homebrew  서비스 확인 :: brew services list / 설치 디렉토리 확인 / brew 서비스 시작

실행 중인 홈브루 서비스를 확인합니다.

$ brew services list

 

mysql 서버가 제대로 설치된 것을 확인할 수 있고, 서비스가 중지되어 있는 것을 확인할 수 있습니다.

jaeui-MacBookPro:~ jaehonghan$ brew services list
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 691, done.
remote: Total 691 (delta 0), reused 0 (delta 0), pack-reused 691
Receiving objects: 100% (691/691), 187.09 KiB | 728.00 KiB/s, done.
Resolving deltas: 100% (272/272), done.
Tapped 1 command (40 files, 260.7KB).
Name    Status  User Plist
emacs   stopped      
mysql   stopped      
unbound stopped   

 

 

설치된 MySQL 데이터 디렉터리를 확인합니다.

$ ls -al /usr/local/var/mysql

jaeui-MacBookPro:~ jaehonghan$ ls -al /usr/local/var/mysql
total 317552
drwxr-x---    2 jaehonghan  admin        64  3 25 21:03 #innodb_temp
drwxr-xr-x   26 jaehonghan  admin       832  3 25 21:03 .
drwxrwxr-x    4 jaehonghan  admin       128  3 25 20:54 ..
-rw-r-----    1 jaehonghan  admin        56  3 25 20:54 auto.cnf
-rw-r-----    1 jaehonghan  admin       178  3 25 21:01 binlog.000001
-rw-r-----    1 jaehonghan  admin       178  3 25 21:03 binlog.000002
-rw-r-----    1 jaehonghan  admin        32  3 25 21:01 binlog.index
-rw-------    1 jaehonghan  admin      1676  3 25 20:54 ca-key.pem
-rw-r--r--    1 jaehonghan  admin      1112  3 25 20:54 ca.pem
-rw-r--r--    1 jaehonghan  admin      1112  3 25 20:54 client-cert.pem
-rw-------    1 jaehonghan  admin      1676  3 25 20:54 client-key.pem
-rw-r-----    1 jaehonghan  admin      3345  3 25 21:03 ib_buffer_pool
-rw-r-----    1 jaehonghan  admin  50331648  3 25 21:03 ib_logfile0
-rw-r-----    1 jaehonghan  admin  50331648  3 25 20:54 ib_logfile1
-rw-r-----    1 jaehonghan  admin  12582912  3 25 21:03 ibdata1
-rw-r-----    1 jaehonghan  admin      2422  3 25 21:03 jaeui-MacBookPro.local.err
drwxr-x---    8 jaehonghan  admin       256  3 25 20:54 mysql
-rw-r-----    1 jaehonghan  admin  28311552  3 25 21:01 mysql.ibd
drwxr-x---  105 jaehonghan  admin      3360  3 25 20:54 performance_schema
-rw-------    1 jaehonghan  admin      1680  3 25 20:54 private_key.pem
-rw-r--r--    1 jaehonghan  admin       452  3 25 20:54 public_key.pem
-rw-r--r--    1 jaehonghan  admin      1112  3 25 20:54 server-cert.pem
-rw-------    1 jaehonghan  admin      1676  3 25 20:54 server-key.pem
drwxr-x---    3 jaehonghan  admin        96  3 25 20:54 sys
-rw-r-----    1 jaehonghan  admin  10485760  3 25 21:03 undo_001
-rw-r-----    1 jaehonghan  admin  10485760  3 25 21:01 undo_002

 

Homebrew MySQL 서비스 시작합니다.

$ brew services start mysql

jaeui-MacBookPro:~ jaehonghan$ brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
jaeui-MacBookPro:~ jaehonghan$ brew services list
Name    Status  User       Plist
emacs   stopped            
mysql   started jaehonghan /Users/jaehonghan/Library/LaunchAgents/homebrew.mxcl.mysql.plist
unbound stopped            

 


MySQL 실행 및 ROOT 비밀번호 설정

 

내 환경설정 파일에 PATH를 설정해 주세요. mysql 부분을 설정하시고 저장하세요.

 

$ vi ~/.bash_profile

$ vi ~/.bash_profile



# mysql 설정부분
export PATH="/usr/local/opt/mysql/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/mysql/lib"
export CPPFLAGS="-I/usr/local/opt/mysql/include"



:wq

 

설정된 내용을 적용시켜 줍니다.

$ source ~/.bash_profile

 

mysql 서버를 실행합니다.

mysql.server start

 

시작해서 SUCCESS! 메세지가 뜨면 mysql서버에 접속해 봅니다. (비밀번호 없이 접속이 가능합니다.)

$ mysql -uroot

jaeui-MacBookPro:~ jaehonghan$ mysql.server start
Starting MySQL
 SUCCESS! 

// Ctrl+ C 를 눌러주세요. 백그라운드로 실행되니 안심하세요.

jaeui-MacBookPro:~ jaehonghan$ mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19 Homebrew

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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> exit

 


MySQL ROOT  비밀번호 설정

1. mysql.server start 명령어로 MySQL 서버를 실행시킵니다.

2. mysql_secure_installation 명령어로 MySQL ROOT비밀번호를 설정합니다.

 

  1. Would you like to setup VALIDATE PASSWORD component?(비밀번호 가이드 설정에 대한 질문)
    yes: 복잡한 비밀번호
    no: 쉬운 비밀번호 --> 쉬운 비밀번호로 세팅해주세요.

  2. Remove anonymous users? (Press y|Y for Yes. any other key for No)(사용자 설정에 관한 질문)
    yes: 접속시 -u 옵션필요
    no: 접속시 -u 옵션 불필요

  3. Disallow root login remotely? (Press y|Y for Yes, any other key for No)(다른 IP에서 root 아이디로 원격접속을 설정)
    yes: 원격접속 불가능
    no: 원격접속 가능

  4. Remove test database and access to it? (Press y|Y for Yes, any other key for No)(테스트 데이터베이스 설정)
    yes: 테스트 데이터베이스 제거
    no: 테스트 데이터베이스 유지

  5. Reload privilege tables now? (Press y|Y for Yes, any other key for No)(변경된 권한을 테이블에 적용)
    yes: 적용
    no: 미적용

$ mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: N
Please set the password for root here.

New password: 

Re-enter new password: 
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done! 

위와 같이 해주시면 root 비밀번호를 간단히 적용하실 수 있습니다.
특히 

VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password
and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?

 

(VALIDATE PASSWORD COMPONENT를 사용하여 비밀번호를 테스트하고 보안을 향상시킬 수 있습니다. 이 체크는 암호의 강도와 충분히 안전한 암호를 설정하여 사용자에게 허용합니다. VALIDATE PASSWORD 구성 요소를 설정 하시겠습니까?)

이 부분에서 "No" 나 "N" 을 눌러주세요.
그렇지 않으시면 아주 긴 비밀번호를 입력해야 할 수도 있습니다.

저의 경우에는 20자 짜리 길이의 비밀번호를 입력했는데요 예상강도가 50이라고 하면서 더 복잡한 암호를 요구하였습니다.

Estimated strength of the password: 50 

 


이런 경우에는 mysql을 재설치하였습니다.

재설치 방법은 아래에 정리해 뒀습니다.

 

 

mysql 서버 접속해봅니다.

$ mysql -uroot 로 하면 에러가 발생합니다.

$ mysql -uroot -p로 해서 설정된 비밀번호를 입력합니다.

 

mysql  로그아웃을 해보세요

mysql >exit 또는 mysql> quit

 

mysql 서버를 종료 해보세요.

$ mysql.server stop


MySQL 삭제 및 재설치 하기

 

brew  서비스에서 mysql 서비스를 중지시킵니다.

$ brew services stop mysql

 

mysql 설치 디렉토리를 삭제합니다.

$ ll /usr/local/var/mysql
$ rm -rf /usr/local/var/mysql

sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/bin/mysql*
sudo rm -rf /usr/local/Cellar/mysql

 

brew 에서 mysql을 언인스톨시킵니다.

$ brew uninstall mysql

 

brew 에서 서비스가 삭제되었는지 확인해 봅니다.
$ brew services list

 

brew 에서 mysql을 인스톨합니다.
$ brew install mysql

 

brew 에서 서비스가 설치되었는지 확인해 봅니다.
$ brew services list

 

$ brew services stop mysql
Stopping `mysql`... (might take a while)
==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)
$ 
$ ll /usr/local/var/mysql
total 221584
drwxr-xr-x  7 jaehonghan  admin       224  3 25 21:10 .
drwxrwxr-x  4 jaehonghan  admin       128  3 25 21:04 ..
-rw-r-----  1 jaehonghan  admin  12582912  3 25 21:10 ibdata1
-rw-r-----  1 jaehonghan  admin  50331648  3 25 21:04 ib_logfile1
-rw-r-----  1 jaehonghan  admin       217  3 25 21:10 ib_buffer_pool
-rw-r-----  1 jaehonghan  admin  50331648  3 25 21:10 ib_logfile0
-rw-r-----  1 jaehonghan  admin    152279  3 25 21:10 jaeui-MacBookPro.local.err
$ rm -rf /usr/local/var/mysql

$ ll /usr/local/var/mysql

$ brew uninstall mysql

Uninstalling /usr/local/Cellar/mysql... (319 files, 232.3MB)


$ brew services list
Name    Status  User Plist
emacs   stopped      
unbound stopped 

$ brew install mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.19.catalina.bottle.2.tar.gz
Already downloaded: /Users/jaehonghan/Library/Caches/Homebrew/downloads/16119cce36310b0d4f34d54a3a0dd701d068e946c1d4bd4c7bb409b9f9899760--mysql-8.0.19.catalina.bottle.2.tar.gz
==> Pouring mysql-8.0.19.catalina.bottle.2.tar.gz
==> /usr/local/Cellar/mysql/8.0.19/bin/mysqld --initialize-insecure --user=jaehonghan --basedir=/usr/local/Cellar/mysql/8.0.19 --datad
==> 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 -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary
🍺  /usr/local/Cellar/mysql/8.0.19: 286 files, 289.2MB

$ brew services list
Name    Status  User Plist
emacs   stopped      
mysql   stopped      
unbound stopped      

 

 

 

참고URL

 

mac에 MySQL 설치하기

https://velog.io/@max9106/mac%EC%97%90-MySQL-%EC%84%A4%EC%B9%98%ED%95%98%EA%B8%B0-4ck17gzjk3

OS X에서 MySQL을 잘못 설치했을 때 다시 설치하는 방법

https://github.com/appkr/l5code/issues/4

728x90

lombok@Slf4j 를 이용해서 

와 같이 코드를 만들어서 사용할려고 할때

"Cannot resolve symbol log" 라는 경고가 뜨면서 실행이 안되는 경우가 있습니다

 

 

이때는 lombok plugin 을 설치해줍니다.

Preferences -> Plugins -> Browse repositories... -> search lombok -> Install "IntelliJ Lombok plugin" 을 설치해 주세요.

그리고 IntelliJ IDE를 재 실행해 주세요.

 
728x90

"System.getProperty()" 사용법

자바를 실행할 때, 실행되는 곳의 정보를 얻어오거나 운영체제의 정보가 필요할 때가 있습니다.
실행 위치에 있는 파일을 읽어드려야 하는데, 현재 위치를 알 수 있는 방법 등 시스템의 정보를 가져올때  System.getProperty() 를 사용합니다.

 

System.getProperty() 으로 괄호 안에 주어진 특정 문자를 적어넣으면 그 값이 String 으로 출력됩니다.

String dir = System.getProperty("user.home");
System.out.println(dir);


// 리눅스 인 경우 /home/유저명/
// macOS인 경우 //Users/유저명/

 

Property 주요 검색어

검색어
java.version Java 버전
java.vendor Java 공급자
java.vendor.url Java 공급자 주소
java.home Java를 설치한 디렉토리
java.class.version Java 클래스 버전
java.class.path Java 클래스 경로
java.ext.dir 확장기능의 클래스 경로
os.name 운영체제 이름
os.arch 운영체제 아키텍처
os.version 운영체제 버전 정보
file.separator 파일 구분 문자
path.separator 경로 구분 문자
line.separator 행 구분 문자
user.name 사용자 계정
user.home 사용자 홈 디렉토리
user.dir

현재 디렉토리

property 확인 메소드해보기

import java.util.Properties;
import java.util.Enumeration;

public class Test {
    public static void main(String[] args) {
        Properties props = System.getProperties();
        for(Enumeration en = props.propertyNames(); en.hasMoreElements();) {
            String key = (String)en.nextElement();
            String value = props.getProperty(key);
            System.out.println(key + "=" + value);
        }
    }

}

 

전혀 없는 키 만들기

전혀 없는 키값인데, System.getProperty("file.location.env"); 라면서 사용하는 경우가 있습니다.

이럴경우, JVM 의 VM arguments 부분을 살펴보면 다음과 같이 세팅되어 있다.

System.getProperty("file.location.env"); 

를 사용하기 위해서 JVM 의 VM arguments 부분에 설정해 주세요.

-Dfile.location.env="./fileUploads/"

 

JVM의 VM arguments 는 JVM을 구동할때, 필요한 여러가지 값을 세팅하는 것인데 -D하고 바로뒤에 키="값"을 세팅하면

프로그램내에서 System.getProperty("키"); 를 통해 값을 가져올 수 있습니다.

 

ava.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition
sun.boot.library.path=C:\Program Files\Java\jdk1.5.0_18\jre\bin
java.vm.version=1.5.0_18-b02
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
path.separator=;
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io
user.country=KR
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=Service Pack 3
java.vm.specification.name=Java Virtual Machine Specification
user.dir=C:\java\client

java.runtime.version=1.5.0_18-b02
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=C:\Program Files\Java\jdk1.5.0_18\jre\lib\endorsed
os.arch=x86
java.io.tmpdir=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\
line.separator=

java.vm.specification.vendor=Sun Microsystems Inc.
user.variant=
os.name=Windows XP
sun.jnu.encoding=MS949
java.library.path=C:\Program Files\Java\jdk1.5.0_18\bin;

java.specification.name=Java Platform API Specification
java.class.version=49.0
sun.management.compiler=HotSpot Client Compiler
os.version=5.1
user.home=C:\Documents and Settings\Administrator
user.timezone=
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=MS949
java.specification.version=1.5
user.name=Administrator
java.vm.specification.version=1.0
sun.arch.data.model=32
java.home=C:\Program Files\Java\jdk1.5.0_18\jre
java.specification.vendor=Sun Microsystems Inc.
user.language=ko
awt.toolkit=sun.awt.windows.WToolkit
java.vm.info=mixed mode, sharing
java.version=1.5.0_18
file.separator=\
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
sun.desktop=windows
sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86

 

출처: https://unabated.tistory.com/entry/Java에서-SystemgetProperty [랄라라]

728x90

MacOS 에서 시스템 폴더에 접근하여 파일을 생성하거나 디렉토리를 만들려고 하니 "Operation not permitted" 라는 메세지가 뜨면서 실행이 안됩니다.

 

 

MacOS 에서 시스템 폴더에 접근하여 파일을 생성하거나 디렉토리를 만들려고 하면  "Operation not permitted" 라는 메세지가 뜨면서 실행이 안됩니다.

저의 경우에는 Apache 웹서버에 특정 파일을 가져다 놓을려고 했는데 위와 같은 에러가 발생하면서 생성이 되지 않았습니다.

이럴 경우에는 SIP (Security Integrity Protection)라고 하는 시스템 무결성 보호(SIP)를 꺼주어야 합니다.

 

시스템 무결성 보호(SIP)란 macOS 시스템 폴더 내에 시스템을 구동하는데 큰 영향을 끼치는 파일들을 보호하기 위해 존재하며, 해당 파일들은 admin 계정으로 접속을 하더라도 수정, 실행, 삭제 등의 제약을 받습니다.

 

즉, 시스템 파일과 폴더를 수정할 가능성을 사전에 차단해 악성 소프트웨어로부터 Mac을 보호해주는 기능입니다.
매우 효과적인 보안기능이지만 사용자가 시스템을 수정하거나 일부 소프트웨어를 사용해야 할 경우에 SIP를 해제해야 합니다.

따라서, 평소에는 SIP 기능이 활성화된 상태로 맥을 사용하며, 필요에 따라 잠깐씩 해제하는 것이 보안 관점에서 바람직합니다

 

 

SIP에 영향으로 내 마음대로 수정/삭제가 불가능한 디렉토리

/System
/sbin
/bin
/usr : /usr/local 디렉토리를 제외한 나머지 서브디렉토리
/Applications : macOS에 기본적으로 설치된 앱(캘린더, 사진, 사파리, 터미널 등


 

SIP기능 비활성하기

1. Mac 재부팅하여 command + R 키를 계속 눌러 Recovery Mode 로 진입합니다.
2. Recovery Mode 에서 Utilities 메뉴에서 Terminal 을 클릭합니다.
3. Terminal 화면에서 "csrutil disable"을 입력합니다.
4. "reboot"을 입력하여 재부팅합니다.

 

 

Recovery Mode (복구모드)에 들어가면 보여지는 화면입니다.

 

$ csrtuil disable

....

$ reboot

위와 같이 하면 재부팅되면서 SIP기능 비활성화 됩니다.


그리고 나서 /usr 나 /etc 에 cp 명령을 해보면 

Read-only file system 

와 같은 에러가 발생합니다.

$ sudo cp libphp5.so /usr/libexec/apache2/
Password:
cp: /usr/libexec/apache2/libphp5.so: Read-only file system

 

그래서 부팅이 되면 터미널에서 다음 커맨드를 입력하여 / 에 대해서도 쓰기가 가능하도록 조치해야 합니다.

$ sudo mount -uw /

이제 / 디렉토리가 쓰기가능하게 바뀌면서 파일을 만들거나 디렉토리를 만들어 줄 수 있게 됩니다.

 

macOS의 시스템 폴더에 대한 권한을 획득하여 작업을 하신 후에 다시 활성화하는게 좋습니다.


SIP기능 활성화하기 - macOS Sierra 10.12.2 이전 버전
1. Mac 재부팅하여 command + R 키를 계속 눌러 Recovery Mode 로 진입합니다.
2. Recovery Mode 에서 Utilities 메뉴에서 Terminal 을 클릭합니다.
3. Terminal 화면에서 "csrutil enable"을 입력합니다.
4. "reboot"을 입력하여 재부팅합니다.

$ csrutil enable

...

$ reboot

 

 

SIP기능 활성화하기 - macOS Sierra 10.12.2 이후 버전

macOS Sierra 10.12.2 이후 버전에서 복구모드로 접근할 필요 없이, 터미널에서 아래 커맨드만 치시면 됩니다.

$ sudo csrutil clear

또는 

$ sudo /usr/bin/csrutil clear

 

< 참조URL >

Mac OS X Operation not Permitted 발생시
https://ellordnet.tistory.com/65
https://luv2irene.tistory.com/12
시스템 무결성 보호(SIP) 상태 해제 및 활성화하는 방법
https://macinjune.com/all-posts/mac/tip/%EC%8B%9C%EC%8A%A4%ED%85%9C-%EB%AC%B4%EA%B2%B0%EC%84%B1-%EB%B3%B4%ED%98%B8sip-%EC%83%81%ED%83%9C-%ED%95%B4%EC%A0%9C-%ED%99%9C%EC%84%B1%ED%99%94-%EB%B0%A9%EB%B2%95/
macOS - Catalina / (root) 에 디렉토리 만들기
https://junho85.pe.kr/1458

+ Recent posts