여러 사람이 공유하여 사용할 목적으로 체계화해 통합, 관리하는 데이터의 집합체
사용자와 데이터베이스 사이에서 사용자의 요구에따라 정보를 생성해주고 데이터베이스를 관리해주는 소프트웨어
서로간에 관계가 있는 데이터 테이블들을 모아둔 데이터 저장공간
데이터 베이스에서 데이터를 정의,조작,제어하기 위해 사용하는 언어
표준이 존재. DBMS마다 추가기능 제공
ㄴ데이터 사이언티스트가 집중해야할 언어: 데이터 조작 언어
show databases;
: 데이터 베이스들 보여주기
USE testdb;
:testdb로 이동
⇊
mysql> use testdb;
Database changed
drop database testdb
:testdb 삭제
⇊
Query OK, 0 rows affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| sys |
| world |
+--------------------+
6 rows in set (0.00 sec)
mysql> use mysql;
mysql> select host, user from user;
⇊
+-----------+------------------+
| host | user |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
4 rows in set (0.00 sec)
CREATE USER 'username'@'localhost' identified by 'password';
⇊
mysql> select host, user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
| localhost | username |
+-----------+------------------+
5 rows in set (0.00 sec)
CREATE USER 'username'@'%' identified by 'password';
mysql> select host, user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | username |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
| localhost | username |
+-----------+------------------+
6 rows in set (0.00 sec)
DROP USER 'username'@'localhost';
DROP USER 'username'@'%';
⇊
mysql> select host, user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
4 rows in set (0.00 sec)
SHOW GRANTS FOR 'me'@'localhost';
⇊
+----------------------------------------+
| Grants for me@localhost |
+----------------------------------------+
| GRANT USAGE ON *.* TO `me`@`localhost` |
+----------------------------------------+
1 row in set (0.00 sec)
GRANT ALL ON dbname.* to 'username'@'localhost';
GRANT ALL ON testdb.* to 'me'@'localhost';
⇊
show grants for 'me'@'localhost';
+--------------------------------------------------------+
| Grants for me@localhost |
+--------------------------------------------------------+
| GRANT USAGE ON *.* TO `me`@`localhost` |
| GRANT ALL PRIVILEGES ON `testdb`.* TO `me`@`localhost` |
+--------------------------------------------------------+
FLUSH PRIVILEGES;
REVOKE ALL ON dbname.* from 'username'@'localhost';
REVOKE ALL ON testdb.* from 'me'@'localhost';
⇊
+----------------------------------------+
| Grants for me@localhost |
+----------------------------------------+
| GRANT USAGE ON *.* TO `me`@`localhost` |
+----------------------------------------+
1 row in set (0.00 sec)