반응형

# mysql -uroot

### 사용자 john(로컬만 접속 가능), steve(로컬, 원격 모두 접속 가능) 생성

MariaDB [(none)]> CREATE USER john@localhost identified by 'john_password';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> CREATE USER steve@'%' identified by 'steve_password';
Query OK, 0 rows affected (0.00 sec)


### 사용자 john은 inventory.* 데이터베이스에서 INSERT, UPDATE, DELETE, SELECT 권한을 준다.

MariaDB [(none)]> GRANT INSERT, UPDATE, DELETE, SELECT on inventory.* to john@localhost;
Query OK, 0 rows affected (0.00 sec)

### 사용자 steve는 inventory.* 데이터베이스에서 SELECT 권한만 준다.

MariaDB [(none)]> GRANT SELECT on inventory.* to steve@'%';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye


# mysql -u john -p

MariaDB [(none)]> use inventory
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [inventory]> SELECT * FROM category;
+----+------------+
| id | name       |
+----+------------+
|  1 | Networking |
|  2 | Servers    |
|  3 | Ssd        |
+----+------------+
3 rows in set (0.00 sec)

MariaDB [inventory]> INSERT INTO category(name) VALUES('Memory');
Query OK, 1 row affected (0.08 sec)

MariaDB [inventory]> UPDATE category SET name='Solid State Drive' where id = 3;
Query OK, 1 row affected (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [inventory]> DELETE FROM category WHERE name LIKE 'Memory';
Query OK, 1 row affected (0.03 sec)





# mysql -u steve -h server11 -p

MariaDB [(none)]> use inventory;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [inventory]> select * from category;
+----+-------------------+
| id | name              |
+----+-------------------+
|  1 | Networking        |
|  2 | Servers           |
|  3 | Solid State Drive |
+----+-------------------+
3 rows in set (0.00 sec)

MariaDB [inventory]> INSERT INTO category(name) VALUES('Memory');
ERROR 1142 (42000): INSERT command denied to user 'steve'@'desktop11.example.com' for table 'category


반응형

'Linux > CentOS' 카테고리의 다른 글

[CentOS7] MariaDB - 4  (0) 2015.03.18
[CentOS7] MariaDB - 3  (0) 2015.03.18
[CentOS7] MariaDB - 1  (0) 2015.03.18
[CentOS7] SAMBA - 3  (0) 2015.03.18
[CentOS7] SAMBA - 2  (0) 2015.03.18
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기