[MySQL] MySQL DB 생성

mysql> create database springDB;

Query OK, 1 row affected (0.00 sec)


mysql> create schema springDB default character set utf8;

Query OK, 1 row affected (0.01 sec)


mysql> create database springDB default character set utf8;


mysql> create database springDB default character set utf8 COLLATE utf8_general_ci;


mysql > create database if not exists springDB default character set utf8 COLLATE utf8_general_ci;


## 각각의 캐릭터 셋을 변경 - 이 변경 방법은 mysql 데몬이 재실행 될경우에 초기화 됨.


mysql> SET character_set_server = utf8;
mysql> SET character_set_client = utf8;
mysql> SET character_set_results = utf8;
mysql> SET character_set_connection = utf8;


mysql> ALTER DATABASE DB명 DEFAULT CHARACTER SET utf8;


[MySQL] DB 캐릭터셋 수정


mysql> alter database springDB default character set utf8 collate utf8_general_ci;

Query OK, 1 row affected (0.02 sec)



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

[MySQL] 계정 생성  (0) 2018.06.16

참조 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