티스토리 뷰
반응형
여러가지 DataBase를 만들다보면 계정별로 권한을 따로 줘야할 일이 많은데 자주 사용하는 계정 관련 SQL 정리 입니다.
mysql 사용
show databases -- 생성된 데이터베이스 목록 보기
use mysql -- 계정, DB, 각종 config 설정은 mysql 데이터 베이스를 사용해야함
계정 조회
select host,user,password from user -- 계정 조회
계정 생성
create user test_user@'localhost' identified by 'insertPassWord'; -- localhost 에서만 계정 접근 허용
create user test_user@'%' identified by 'insertPassWord'; -- 모든IP 의 계정 접근 허용
create user test_user@'192.168.*.*' identified by 'insertPassWord'; -- 192.168로 시작하는 IP만 계정 접근 허용
계정 삭제
drop user test_user -- 계정 삭제
MySQL은 UserID, PassWord, Host를 사용하여 계정 인증을 진행함.
로그인을 시도하는 위치(HOST) 또한 인증의 일부로 사용되어 Host를 localHost로만 줄 경우,
다른 컴퓨터에서 DB에 붙을 수 없는 상황 발생 할 수 있으니 주의
권한 부여
GRANT ALL PRIVILEGES ON testDataBase.* TO test_user@'%' ; --권한부여
-> 모든 IP로 접속한 test_user에게 testDataBase의 모든 테이블의 모든 권한을 부여함
GRANT SELECT on *.* to test_user@'192.168.*.*' -- 권한 부여
-> 192.168로 시작하는 IP로 접속한 test_user에게 모든 데이터베이스의 모든 테이블의 SELECT 권한 부여함
SHOW GRANTS FOR test_user@'%'; -- 부여된 권한 확인
권한 삭제
revoke all on *.* from test_user; -- 권한 삭제, 계정이 삭제되는것은 아님
항상 마무리엔 메모리에 변경 내용 반영 필수
flush privileges; -- 변경된 내용을 메모리에 반영해줘야함
반응형
'SQL' 카테고리의 다른 글
[SQL] MySQL Date Type between 과 대소 비교 연산자(>,<) 성능 비교 (0) | 2023.02.05 |
---|---|
[SQL] mySQL Procedure 사용하여 반복문 사용하기 (0) | 2023.02.05 |
[SQL] mySQL Query 사용 데이터 암호화 (0) | 2021.11.12 |
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- react #img 전송
- docker mysql
- see ec2 instance connect prerequisites at https://docs.aws.amazon.com/awsec2/latest/userguide #인스턴스 연결 안됨
- linux/amd64/v2
- excel 파일 만들기 #node.js #express excel 파일 만들기 #데이터 입력해서 excel 파일 만들기
- 이미지 전송 # 이미지 업로드 #이미지 여러장 #이미지 여러장 업로드 #react 이미지 업로드 #react 이미지 여러장 업로드
- ERROR: failed to solve: no support for running processes with linux/amd64/v3 platform
- reack-cookies #아이디 저장하기 #react 아이디 저장 #react cookie #리엑트 아이디 저장하기
- Express multer #Express File 저장 #node.js
- mysql date type
- react #react-spinners #modal loading #overlay #로딩창 #react 로딩창 만들기
- Pytorch #Yolov5 #Segementation
- mysql date between # mysql date between 대소 비교 연산자
- React filter #js Includes #React Filter includes
- PDF #pdfkit
- Swal #sweetalert2 #alert #알림창 띄우기 #react swal
- FormData #FormData 파일전송 #FormData append json # React FormData File #React FormData append Json
- node.js 파일 저장
- AWS #인바운드 #SSH #인스턴스 연결
- JavaScript #Programmers #lvl2 #프로그래머스 오픈채팅방 # 오픈채팅방 문제
- BOJ #JS
- supported: linux/amd64
- mysql date between performance
- Mac docker.for.mac.host.internal
- Procedure #mysql #mysql Procedure #mysql 반복문 #Procedure 반복문 #mysql insert 반복문
- mysql date
- ec2 instance connect is unable to connect to your instance. ensure your instance network settings are configured correctly for ec2 instance connect. for more information
- node.js #node.js pdf만들기 #node.js pdfkit
- PoolCluster : Error: connect ECONNREFUSED 127.0.0.1:3306)
- docker # docker build # m1 docker build
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함