USER 생성하기

정의

mysql>create user <유저명>@<접속할 ip>;

mysql>set password for <유저명>@<접속할 ip>=password('<password>');

예제

mysql> create user user2@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> set password for user2@localhost = password('1234');
Query OK, 0 rows affected, 1 warning (0.00 sec)

권한주기

정의

garnt <권한> on <데이터베이스,테이블? to <id@ip> identified by <'password'>

줄 수 있는 권한
ALTER, CREATE, DELETE, DROP, INDEX, INSERT, SELECT, UPDATE, DELETE, INSERT, SELECT, UPDATE,ALL

예제
-설정전
$ mysql -u user2 -p

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+

-설정하기

$ mysql -u root -p
mysql> grant select on school.* to user2@localhost identified by '1234';

-설정후
$ mysql -u user2 -p
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| school             |
+--------------------+

권한 보기 및 삭제

권한 보기

정의 show grants for <사용자>

예제 mysql> show grants for user1; 
+-------------------------------------------+ 
| Grants for user1@% |
+-------------------------------------------+ 
|GRANT USAGE ON _._ TO 'user1'@'%' | 
| GRANT SELECT ON `school`.* TO 'user1'@'%' | 
+-------------------------------------------+
2 rows in set (0.00 sec)

mysql> show grants; 
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+ 
| GRANT ALL PRIVILEGES ON _._ TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION 
| +---------------------------------------------------------------------+

권한삭제

정의 mysql>revoke <권한> on <database>. from <사용자>;</database>

예제 mysql> revoke select on school.* from user1; Query OK, 0 rows affected (0.00 sec)

<table></table>

'리눅스' 카테고리의 다른 글

aws <php와mysql 연결하기>  (0) 2018.01.01
AWS웹 어플리케이션  (0) 2018.01.01
MYSQL2  (0) 2017.12.29
MYSQL1  (0) 2017.12.27
aws  (0) 2017.12.27

+ Recent posts