DB) DB 접속

YIHN·2024년 5월 8일

DB/SQL

목록 보기
9/10
post-thumbnail

이 편은 MySQL으로 진행합니다.

  1. Docker MySQL 접속
docker exec -it 컨테이너명 /bin/bash
  1. mysql에 root 계정으로 접속
mysql -u root -p
  1. mysql로 전환..?
use mysql;

사용자 조회 및 권한 부여

사용자 목록 조회

select user, host from user;

사용자 생성

create user '[name]'@'localhost' identified by '[password]';

사용자에 권한 부여

사용자 생성 + 권한 부여

mysql 8.x부터는 grant all로 사용자 생성 및 권한 동시 부여 불가능

mysql 8.x부터 사용자 생성, 권한 부여 방법

create user '[name]'@'%' identified by '[password]'; 
grant super on *.* to 'yihn'@'%';
grant all privileges on *.* to 'yihn'@'%';

사용자 권한 확인

show grants for '[name]'@'%';

사용자 권한 수정, 삭제

drop user '[name]'@'localhost';
profile
오늘도 YIHN

0개의 댓글