-- root 계정 생성
-- : 외부 노출 금지
ALTER USER 'root'@'localhost' IDENTIFIED BY 'snowman123*';
CREATE USER IF NOT EXISTS 'root'@'127.0.0.1';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY 'snowman123*' WITH GRANT OPTION;
CREATE USER IF NOT EXISTS 'root'@'::1';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'::1' IDENTIFIED BY 'snowman123*' WITH GRANT OPTION;



-- Administrator 계정 생성
-- : 지정한 외부 IP에서만 사용 가능
CREATE USER IF NOT EXISTS 'Administrator'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'Administrator'@'localhost' IDENTIFIED BY 'snowman123*';
CREATE USER IF NOT EXISTS 'Administrator'@'127.0.0.1';
GRANT ALL PRIVILEGES ON *.* TO 'Administrator'@'127.0.0.1' IDENTIFIED BY 'snowman123*';
CREATE USER IF NOT EXISTS 'Administrator'@'::1';
GRANT ALL PRIVILEGES ON *.* TO 'Administrator'@'::1' IDENTIFIED BY 'snowman123*';
CREATE USER IF NOT EXISTS 'Administrator'@'192.168.%.%';
GRANT ALL PRIVILEGES ON *.* TO 'Administrator'@'192.168.%.%' IDENTIFIED BY 'snowman123*';
CREATE USER IF NOT EXISTS 'Administrator'@'59.6.184.215';
GRANT ALL PRIVILEGES ON *.* TO 'Administrator'@'59.6.184.215' IDENTIFIED BY 'snowman123*';
CREATE USER IF NOT EXISTS 'Administrator'@'121.160.168.106';
GRANT ALL PRIVILEGES ON *.* TO 'Administrator'@'121.160.168.106' IDENTIFIED BY 'snowman123*';



-- GameManager 계정 생성
-- : 주기적인 관리나 운영 툴 같은데서 쓰는 계정
--   꼭 필요한 권한만 주어진다.
--   지정한 외부 IP에서만 사용 가능
CREATE USER IF NOT EXISTS 'GameManager'@'localhost';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_global`.*
TO 'GameManager'@'localhost'IDENTIFIED BY 'Nox1q2w3e4r';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_configuration`.*
TO 'GameManager'@'localhost';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_authentication`.*
TO 'GameManager'@'localhost';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_game`.*
TO 'GameManager'@'localhost';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_community`.*
TO 'GameManager'@'localhost';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_log`.*
TO 'GameManager'@'localhost';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_tool`.*
TO 'GameManager'@'localhost';

CREATE USER IF NOT EXISTS 'GameManager'@'127.0.0.1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_global`.*
TO 'GameManager'@'127.0.0.1'IDENTIFIED BY 'Nox1q2w3e4r';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_configuration`.*
TO 'GameManager'@'127.0.0.1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_authentication`.*
TO 'GameManager'@'127.0.0.1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_game`.*
TO 'GameManager'@'127.0.0.1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_community`.*
TO 'GameManager'@'127.0.0.1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_log`.*
TO 'GameManager'@'127.0.0.1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_tool`.*
TO 'GameManager'@'127.0.0.1';

CREATE USER IF NOT EXISTS 'GameManager'@'::1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_global`.*
TO 'GameManager'@'::1'IDENTIFIED BY 'Nox1q2w3e4r';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_configuration`.*
TO 'GameManager'@'::1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_authentication`.*
TO 'GameManager'@'::1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_game`.*
TO 'GameManager'@'::1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_community`.*
TO 'GameManager'@'::1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_log`.*
TO 'GameManager'@'::1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_tool`.*
TO 'GameManager'@'::1';

CREATE USER IF NOT EXISTS 'GameManager'@'192.168.%.%';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_global`.*
TO 'GameManager'@'192.168.%.%'IDENTIFIED BY 'Nox1q2w3e4r';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_configuration`.*
TO 'GameManager'@'192.168.%.%';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_authentication`.*
TO 'GameManager'@'192.168.%.%';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_game`.*
TO 'GameManager'@'192.168.%.%';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_community`.*
TO 'GameManager'@'192.168.%.%';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_log`.*
TO 'GameManager'@'192.168.%.%';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_tool`.*
TO 'GameManager'@'192.168.%.%';

CREATE USER IF NOT EXISTS 'GameManager'@'59.6.184.215';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_global`.*
TO 'GameManager'@'59.6.184.215'IDENTIFIED BY 'Nox1q2w3e4r';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_configuration`.*
TO 'GameManager'@'59.6.184.215';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_authentication`.*
TO 'GameManager'@'59.6.184.215';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_game`.*
TO 'GameManager'@'59.6.184.215';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_community`.*
TO 'GameManager'@'59.6.184.215';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_log`.*
TO 'GameManager'@'59.6.184.215';
GRANT
	INSERT, SELECT, UPDATE, DELETE, CREATE, DROP, EVENT, CREATE VIEW, SHOW VIEW, EXECUTE, LOCK TABLES, ALTER ROUTINE, CREATE ROUTINE
ON `eod_tool`.*
TO 'GameManager'@'59.6.184.215';




-- GameUser 계정 생성
-- : 게임 서버의 내부 구현에 의한 DB 질의를 처리하기 위한 용도
--   매우 제한적인 권한만 주어진다.
CREATE USER IF NOT EXISTS 'GameUser'@'localhost';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_global`.*
TO 'GameUser'@'localhost' IDENTIFIED BY 'Nox1q2w3e4r';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_configuration`.*
TO 'GameUser'@'localhost';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_authentication`.*
TO 'GameUser'@'localhost';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_game`.*
TO 'GameUser'@'localhost';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_community`.*
TO 'GameUser'@'localhost';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_log`.*
TO 'GameUser'@'localhost';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_tool`.*
TO 'GameUser'@'localhost';

CREATE USER IF NOT EXISTS 'GameUser'@'127.0.0.1';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_global`.*
TO 'GameUser'@'127.0.0.1' IDENTIFIED BY 'Nox1q2w3e4r';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_configuration`.*
TO 'GameUser'@'127.0.0.1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_authentication`.*
TO 'GameUser'@'127.0.0.1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_game`.*
TO 'GameUser'@'127.0.0.1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_community`.*
TO 'GameUser'@'127.0.0.1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_log`.*
TO 'GameUser'@'127.0.0.1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_tool`.*
TO 'GameUser'@'127.0.0.1';

CREATE USER IF NOT EXISTS 'GameUser'@'::1';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_global`.*
TO 'GameUser'@'::1' IDENTIFIED BY 'Nox1q2w3e4r';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_configuration`.*
TO 'GameUser'@'::1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_authentication`.*
TO 'GameUser'@'::1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_game`.*
TO 'GameUser'@'::1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_community`.*
TO 'GameUser'@'::1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_log`.*
TO 'GameUser'@'::1';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_tool`.*
TO 'GameUser'@'::1';

CREATE USER IF NOT EXISTS 'GameUser'@'%';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_global`.*
TO 'GameUser'@'%' IDENTIFIED BY 'Nox1q2w3e4r';
GRANT 
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_configuration`.*
TO 'GameUser'@'%';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_authentication`.*
TO 'GameUser'@'%';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_game`.*
TO 'GameUser'@'%';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_community`.*
TO 'GameUser'@'%';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_log`.*
TO 'GameUser'@'%';
GRANT
	INSERT, SELECT, UPDATE, DELETE, EXECUTE
ON `eod_tool`.*
TO 'GameUser'@'%';

FLUSH PRIVILEGES;