안녕하세요 유즈입니다. 피드백은 언제나 감사합니다.^^
접속 방법과 문법 등을 기본적인 실습을 통해 공부하고 그 기록을 남겨볼까 합니다.
오늘 실습한 내용)
1. 사용자 계정 'honggildong' 만들기. 비밀번호는 1234
2. DB hong_db 만들기.
3. honggildong 계정이 데이터베이스 hong_db 한테 12가지 모든 권한 주기.
4. honggildong 계정으로 들어가 DB 보고 나오기.
5. 비밀번호 abc로 바꾸기.
cmd로 프롬프트 실행 후
C:\Users\이유진>cd c:\ c:\>cd apm_setup c:\APM_Setup>cd server c:\APM_Setup\Server>cd mysql c:\APM_Setup\Server\MySQL>cd bin c:\APM_Setup\Server\MySQL\bin>mysql -uroot -p Enter password: ******** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 14 to server version: 4.0.18-max-debug Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
접속해 줍니다.
mysql> use mysql Database changed mysql> select user,password from user; +-------------+------------------+ | user | password | +-------------+------------------+ | root | 659210f56d1f4484 | | nalog | 659210f56d1f4484 | | heo2 | 1234 | | lee | 446a12100c856ce9 | | lyj | 565491d704013245 | +-------------+------------------+
생성할 계정의 user 가 겹치는 게 있는지 확인했습니다. (생략 가능)
insert into user (host, user, password) values (‘localhost’, ‘honggildong’, ‘password(1234’)); Query OK. 1 row affected (0.00 sec) mysql> select user,password from user; +-------------+------------------+ | user | password | +-------------+------------------+ | root | 659210f56d1f4484 | | nalog | 659210f56d1f4484 | | heo2 | 1234 | | lee | 446a12100c856ce9 | | lyj | 565491d704013245 | | honggildong | 565491d704013245 | +-------------+------------------+ 6 rows in set (0.01 sec)
1. honggildong 의 계정을 비밀번호와 함께 추가해 준 후,
select 문을 이용해 정상적으로 잘 들어갔는지 확인까지 해줍니다.
(혹시 잘못 쳐서 작성한 홍길동계정을 삭제하고 싶다면
delete from user where user='honggildong'; )
비밀번호 란에 password('~') 하는 이유는 암호화 하기 위해서 입니다. 암호화 안하면 생성된 계정으로 들어가지지않음.
만약 암호화 안하고 만들었다면
update user set password = password('~') where user = 'leeik';
으로 삭제하지 않고 간단히 수정할 수 있습니다.
mysql> create database hong_db; Query OK, 1 row affected (0.00 sec)
2. hong_db 데이터베이스 생성을 합니다.
생성 후 확인하고 싶으시다면 show databases; 을 활용하시면 됩니다.
mysql> insert into db values ('localhost', 'hong_db', 'honggildong', 'y', 'y', 'y' , 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y'); Query OK, 1 row affected (0.01 sec) mysql> select * from db; +-----------+----------+------------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+ | Host | Db | User | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Create_tmp_table_priv | Lock_tables_priv | +-----------+----------+------------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+ | localhost | db_nalog | nalog | Y | Y | Y | Y | Y | Y | N | N | Y | Y | Y | N | | localhost | kim_db | kim | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | localhost | hong_db | hongildong | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | +-----------+----------+------------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+ 3 rows in set (0.01 sec)
3. 홍길동 계정이 홍db 계정에게 12가지의 모든 권한을 주고,
select 문으로 확인까지 했습니다. N 에서 Y로 변한 것을 볼 수 있습니다.
mysql> flush privileges; Query OK, 0 rows affected (0.02 sec) mysql> exit Bye
변경내용을 저장해준 후 ,
빠져나옵니다.
c:\APM_Setup\Server\MySQL\bin>mysql -uhonggildong -p1234 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 to server version: 4.0.18-max-debug Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
4. hong 계정에 접속이 정상적으로 이뤄진 것을 볼 수 있습니다.
show databases; 을 통해 db 도 확인해줍니다.
c:\APM_Setup\Server\MySQL\bin>mysql -uhonggildong -p123456 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 to server version: 4.0.18-max-debug Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> update user set password=password('abc') where user='honggildong'; Query OK, 1 row affected (0.01 sec) 일치하는 Rows : 1개 변경됨: 1개 경고: 0개 mysql> flush privileges; Query OK, 1 row affected (0.03 sec) mysql> exit Bye
5. 변경 전 홍길동 계정으로 들어간 후 ,
비밀번호를 abc로 바꿔줍니다.
변경 내용을 flush 문을 통해 저장 후,
종료합니다.
간단하게 계정 생성부터 비밀번호 변경 완료 되었습니다.
'RDB > MySQL' 카테고리의 다른 글
mysql 기본 명령어, 기본 함수 (0) | 2021.01.21 |
---|---|
php로 작성 , Mysql과 연동 (성적입력 홈페이지) (0) | 2021.01.21 |
MySQL 실습 (3) - 필드 추가,삭제,데이터 변경. desc,alter,drop,where (0) | 2021.01.14 |
MySQL 기초실습(2) - 지정한 DB에 table 생성, 데이터 넣기 (0) | 2021.01.14 |