Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Tags
more
Archives
Today
Total
관리 메뉴

삐뚜루빠뚜루빼뚜루

[Linux] SQL 실습 본문

실습문제/linux

[Linux] SQL 실습

삐.빠.빼 2025. 3. 27. 15:39


[실습 전]

1. Maria DB 설치

2. Maria DB 서비스 시작

3. Maria DB 데몬 자동실행 설정


[실습문제]

1. MySQL 한글 설정 후 캐릭터셋이 utf-8로 변경되었는지 결과 확인.

vi /etc/my.cnf

/etc/my.cnf 수정 전

[mysqld]
character_set_server=utf8

[client]
default_character_set=utf8

/etc/my.cnf 수정 후

service mariadb restart

mysql -u root -p
// mysql 첫 접속시 pw는 없음

mariadb 서비스 재시작 및 sql 접속
\s 입력 server/db characterset : utf8 확인

 

2. korea DB 생성 및 class table을 만든 후 테이블 정보출력

create database korea; // korea 데이터베이스 생성
use korea; // 생성한 korea로 접속

생성 및 접속

cearte table class (
no int auto_increment primary key,
id char(40) not null,
pw char(40) not null,
nick varchar(40) not null,
reg_date datetime,
unique sevas(id)
);
// class 테이블 생성


dasc class; // korea db의 class 테이블 출력

테이블 확인 및 class 확인

 

3. MySQL에 접속 후 root계정 pw를 *12ya~ 변경 후 select로 출력

use mysql; //mysql  접속

select user,host,password from user; // user테이블의 user,host,password 정보 검색

update user set password=password('*12ya~') where user='root';
//root에 대한 password를 *12ya~로 변경

flush privileges; //정보저장

select user,host,password from user;

 

4. MySQL 데이터베이스 전체를 백업하는 mysql.sql 파일을 만들고 생성확인

mysqldupm -u root -p*12ya~ -A > mysql.sql
//데이터베이스 전체 db 백업

 

5. 해당 DB 데이터(sevas)의 pw(asd123)을 암호화하여 select로 출력

* aes_encrtpy, sha2,256, key(sevas)

use korea;
inster into class vlaues(null,'sevas','asd123','세바스',now());
select * from class;

select id, hax(aes_encrtpy(pw,sha2('sevas',256))) from class;

 

6. 위 문제에서 입력한 데이터를 다음과 같이 암호화된 데이터로 update 후 select를 통해 복호화 출력

update class set pw=hax(aes_encrtpy(sha2('sevas',256)));

select * from class;

select id,ase_decrypt(unhex(pw),sha2('sevas',256)) from class;

'실습문제 > linux' 카테고리의 다른 글

[Linux] 계정 / 마운트 / DNS / 웹페이지 실습  (0) 2025.03.08
[Linux] DNS 설정실습  (0) 2025.03.02
[Linux]NAT 및 NMAP 스캔 연습  (0) 2025.02.07
[Linux] 리눅스 계정 실습  (0) 2025.01.31
[Linux] 실습문제[24.12.23]  (0) 2025.01.24