#@localhost는 내부접근 @"%" 외부 접근 허용이고 ""를 붙이는건 상관없다.
create user test2@localhost identified by "user1234";
create user "test3"@"%" identified by "1234";v
user 생성 후 권한 주기 all privileges on은 모든 권한을 주는것
mysql 8.0 이후부터는 생성하면서 권한을 주지 못함
create user "test4"@"localhost" identified by "1234";
grant all privileges on *.* to "test4"@"localhost" with grant option;
#권한 해제
revoke grant option on *.* from "test4"@"localhost";
roll 생성 해서 권한 주기
#roll 생성
CREATE ROLE 'app_read', 'app_write';
#roll에 권한 부여
GRANT SELECT ON stock.* TO 'app_read';
GRANT INSERT, UPDATE, DELETE ON stock.* TO 'app_write';
#test1 유저에 roll 뷰여
GRANT 'app_read' TO test1@localhost;
GRANT 'app_read','app_write' to 'test2'@'localhost';
#권한보기
SHOW GRANTS FOR 'app_read'@'%';
SHOW GRANTS FOR 'test2'@'localhost';
SHOW GRANTS FOR 'test2'@'localhost' USING 'app_read';
select current_role();
#root로 접속하여 DEFALUT 활성화 셋팅 및 ROLE 활성화 계정 설정
SET DEFAULT ROLE ALL TO
'test2'@'localhost',
'test1'@'localhost';
'sql' 카테고리의 다른 글
주식 데이터로 sql 연습 (section 3) (0) | 2022.07.19 |
---|---|
mysql 터미널 접속 및 사용법 (0) | 2022.07.19 |
주식 데이터로 sql 연습 (section 2) (0) | 2022.07.17 |
python 상장 기업 정보 mysql에 insert하기 (0) | 2022.07.16 |
주식 데이터로 sql 연습 (section 1) (0) | 2022.07.13 |