참조 http://link2me.tistory.com/431


[MySQL] DB 로그인


C:\Users\SeokRae Kim>mysql -u root -p

Enter password: ****

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 161

Server version: 5.7.22-log MySQL Community Server (GPL)


Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql>



[MySQL] DB 계정 생성


mysql> create user 'springDBA'@'%' identified by '1234'; // 외부에서의 접근을 허용

Query OK, 0 rows affected (0.00 sec)


[MySQL] MySQL DB 사용


mysql> use mysql;

Database changed


[MySQL] MySQL 사용자 DB 생성


mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| pjt2               |

| sakila             |

| sys                |

| world              |

+--------------------+

7 rows in set (0.02 sec)


[MySQL] 사용자 확인


mysql> select user from user;

+---------------+

| user              |

+---------------+

| springDBA       |

| boostcourse     |

| mysql.session   |

| mysql.sys        |

| root               |

+---------------+

5 rows in set (0.00 sec)


[MySQL] 사용자 확인

mysql> select host, user, authentication_string from user;

+-----------+---------------+-------------------------------------------+

| host      | user          | authentication_string                                     |

+-----------+---------------+-------------------------------------------+

| localhost | root          | *A4B6157319038724E3560894F7F932C8886EBFCF     |

| localhost | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |

| localhost | mysql.sys     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |

| %         | boostcourse   | *A4B6157319038724E3560894F7F932C8886EBFCF |

+-----------+---------------+-------------------------------------------+

4 rows in set (0.00 sec)


[MySQL] 사용자 권한 부여


 - 일반사용자

mysql> grant all privileges on springDBA.* to springDBA@localhost identified by '1234' with grant option;

Query OK, 0 rows affected, 1 warning (0.00 sec)


 - 특정 DB의 모든 권한

mysql> grant all privileges on springDB.* to springDBA@'%';

Query OK, 0 rows affected (0.00 sec)


 - 모든 곳에서 원격 접근 가능

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

Query OK, 0 rows affected (0.02 sec)


[MySQL] 사용자 권한 확인

mysql> show grants for springDBA@'%';

+---------------------------------------------------------+

| Grants for springDBA@%                                  |

+---------------------------------------------------------+

| GRANT USAGE ON *.* TO 'springDBA'@'%'                   |

| GRANT ALL PRIVILEGES ON `springdb`.* TO 'springDBA'@'%' |

+---------------------------------------------------------+

2 rows in set (0.00 sec)


[MySQL] 메모리 반영


mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

'DB > MySQL' 카테고리의 다른 글

[MySQL] Database 생성  (0) 2018.06.17

+ Recent posts