R&D/database

mysql

sunshout 2017. 2. 17. 20:00

계정을 생성하고 모든 권한을 주고 싶을 때

mysql> create user 'choonho'@'%' identified by 'choonho';

Query OK, 0 rows affected (0.00 sec)


mysql> grant all on *.* to 'choonho'@'%';

Query OK, 0 rows affected (0.01 sec)


mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)




read 권한만 주고 싶을 때

create user 'telegraf'@'localhost' identified by 'telegraf_pw';

GRANT SELECT, SHOW VIEW  ON *.* TO 'telegraf'@'localhost';


bash에서 

mysql -e "create user 'telegraf'@'localhost' identified by 'telegraf_pw'"

mysql -e "GRANT SELECT, SHOW VIEW ON *.* TO 'telegraf'@'localhost'"