MySQL 계정(사용자) 생성 및 권한 설정 방법 정리


MySQL 서버 설치

별도 정리중

MySQL 클라이언트 접속

/usr/local/mysql/bin/mysql -u root -p    ⏎
패스워드    ⏎

DB(스키마) 생성

∙ DB 확인

show databases;


DB 생성(기본 캐릭터셋을 utf8)

create database DB명 default character set utf8;



DB 사용

use DB명


계정(사용자) 생성

mysql DB 사용

use mysql


계정 확인

select user, host from user;


계정 생성

create user '계정명'@'host' identified by '패스워드';

host 는 localhost 와 % 가 있음

localhost 는 내부 접근, % 는 외부 접근 허용


계정 삭제

drop user '계정명';

사용자 권한 부여

권한 확인

show grants for '계정명';


권한 부여

grant [권한 종류] on DB명.테이블명 to '사용자명’@'host’ (identified by ‘패스워드');

권한 종류에는 select, insert, update, delete 가 있음

모든 권한을 부여 시 all privileges

DB명과 테이블명은 * 로 모든 것을 지정 가능하다

예시) grant all privileges on *.* to 'scott'@localhost identified by 'tiger';

+ Recent posts