[MySQL] MySQL 5.7 user 생성, 권한 부여

치치·2021년 4월 16일
0

MySQL 관리

목록 보기
1/1

사용자 등록

데이터베이스에 접근하는 사용자를 먼저 등록한다. 요청하는 출발지에 따라 약간?씩 다르다.

  1. localhost
mysql> insert into user(host, user, authentication_string, ssl_cipher, x509_issuer, x509_subject)
values('localhost', '계정', password('비밀번호'), '', '', '');
  1. 127.0.0.1
mysql> insert into user(host, user, authentication_string, ssl_cipher, x509_issuer, x509_subject) 
values('127.0.0.1', '계정', password('비밀번호'), '', '', '');
  1. 외부접속
mysql> insert into user(host, user, authentication_string, ssl_cipher, x509_issuer, x509_subject) 
values('%', '계정', password('비밀번호'), '', '', '');
  1. 생성한 후 서버에 적용하려면 flush를 해주자.
mysql> flush privileges;

접속 권한 부여

사용자만 생성한다 해서 접속되지 않는다.
접속 권한을 부여해야 한다.
사용자 생성과 마찬가지로 출발지에 따라 약간?씩 다르다.

mysql> grant all privileges on _university.* to 계정@localhost identified by '비밀번호' with grant option;

mysql> grant all privileges on _university.* to 계정@127.0.0.1 identified by '비밀번호' with grant option;

mysql> grant all privileges on _university.* to '계정'@'%' identified by '비밀번호' with grant option;

그리고 마지막은

mysql> flush privileges;

!mysql !grant !권한 !사용자등록

profile
안녕하세요. 개발자입니다.

0개의 댓글