Create MySQL Users Accounts and Grant Privileges

์ ๋Š”์ž๊ฐ€ ์‚ด์•„๋‚จ๋Š”๋‹ค.........

MySQL ๊ณ„์ • ์ƒ์„ฑํ•˜๊ธฐ

mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
  • ๋‹ค๋ฅธ Host๋กœ๋ถ€ํ„ฐ์˜ ์ ‘์†์„ ํ—ˆ์šฉํ•˜๋ ค๋ฉด localhost ์œ„์น˜์— IP Address ์ ์œผ๋ฉด ๋œ๋‹ค

  • ๋ชจ๋“  Host๋กœ๋ถ€ํ„ฐ์˜ ์ ‘์†์„ ํ—ˆ์šฉํ•˜๋ ค๋ฉด '%' wildcard๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค

grant ๋ช…๋ น์–ด๋กœ ์‚ฌ์šฉ์ž ๊ถŒํ•œ ์„ค์ •ํ•˜๊ธฐ

์‚ฌ์šฉ์ž ๊ถŒํ•œ ์„ค์ •

mysql> GRANT ALL PRIVILEGES ON dbname.table TO 'userID'@'host' IDENTIFIED BY 'password';

๋ชจ๋“  db ๋ฐ table์— ์ ‘๊ทผ ๊ถŒํ•œ ์„ค์ •

mysql> GRANT ALL PRIVILEGES ON *.* TO userID@host IDENTIFIED BY 'password';

๋ชจ๋“  db ๋ฐ ํ…Œ์ด๋ธ”์— ๊ถŒํ•œ์„ ์ฃผ๊ณ  ๋กœ์ปฌ ๋ฐ ๋ฆฌ๋ชจํŠธ์—์„œ๋„ ์ ‘์†๊ฐ€๋Šฅํ•˜๋„๋ก ์„ค์ •

mysql> GRANT ALL PRIVILEGES ON *.* to userID@'%' IDENTIFIED BY 'password';

์„ค์ •ํ•œ ๊ถŒํ•œ ์ ์šฉ

mysql> FLUSH PRIVILEGES;
  • ์‹คํ–‰ํ•ด์•ผ ์ ์šฉ๋œ๋‹ค!

๊ถŒํ•œ ์‚ญ์ œ

mysql> REVOKE ALL ON dbname.table FROM userID@host

๊ถŒํ•œ ์กฐํšŒ

mysql> SHOW GRANTS FOR userID@host

Last updated