DataBase
[AWS] aws rds mysqlbinlog 까보기, 확인 방법
이영서
2024. 4. 25. 13:31
bin log 보존기간 확인
mysql> call mysql.rds_show_configuration;
bin log 존재 확인
mysql> show binary logs;
+----------------------------+-----------+-----------+
| Log_name | File_size | Encrypted |
+----------------------------+-----------+-----------+
| mysql-bin-changelog.000022 | 65666285 | No |
+----------------------------+-----------+-----------+
1 row in set (0.01 sec)
먼저 binlog가 있는지 확인한다.
이걸 열어봐야하니 로컬에 다운로드 해준다
[root@DESKTOP-9H4FBAA ~]# mysqlbinlog \
> --read-from-remote-server \
> --host=sample.rds.amazonaws.com \
> --port=3306 \
> --user root \
> --password \
> --raw \
> --verbose \
> --result-file=/D: \
> mysql-bin-changelog.000022
Enter password: ERROR: Could not find server version: Master reported unrecognized MySQL version '8.0.28'.
에러가 나왔는데 내 로컬에 MySQL 5.7이 깔려있었다
그래서 우분투로 다시 함(내 우분투는 mysql 8.0이 깔려있음..미리 안깔아뒀으면 어쩔뻔..)
(주의)
여기 윈도우 아니니까 --result-file=/mnt/d/ 로 반드시 해줘야함;
D 그대로 하면 안된다
mysqlbinlog \
--read-from-remote-server \
--host=sample.rds.amazonaws.com \
--port=3306 \
--user root \
--password \
--raw \
--verbose \
--result-file=/mnt/d/ \
mysql-bin-changelog.000022
리눅스에 맞게 /mnt/d로 수정 뒤 D드라이브 안에 다운된 걸 확인
cd /mnt/d
한 다음
mysqlbinlog -vv --base64-output=DECODE-ROWS mysql-bin-changelog.000022 > query2.sql
바이너리파일이라 무조건 변환 후 확인할수 있다.