Lab 12: Database Encryption
Overview
Step 1: MySQL InnoDB Tablespace Encryption — Setup
docker run -d --name mysql-lab \
-e MYSQL_ROOT_PASSWORD=rootpass \
mysql:8.0 \
--early-plugin-load=keyring_file.so \
--keyring_file_data=/var/lib/mysql-keyring/keyring \
--default_table_encryption=ON
for i in $(seq 1 30); do docker exec mysql-lab mysql -uroot -prootpass -e "SELECT 1" 2>/dev/null && break || sleep 2; done
# Check encryption capability
docker exec mysql-lab mysql -uroot -prootpass -e "
SHOW VARIABLES LIKE 'default_table_encryption';
SHOW VARIABLES LIKE 'keyring_file_data';
SELECT * FROM performance_schema.keyring_keys;
"Step 2: Create Encrypted vs Unencrypted Tables
Step 3: Verify Encryption at Rest (Binary Inspection)
Step 4: MySQL — Require Secure Transport (SSL/TLS)
Step 5: PostgreSQL pgcrypto — Application-Level Encryption
Step 6: pgcrypto — Decrypt and Hash Functions
Step 7: PostgreSQL SSL/TLS — Verify Encrypted Connections
Step 8: Capstone — TDE Concept and pgcrypto Key Rotation
Summary
Encryption Type
MySQL
PostgreSQL
Protects Against
pgcrypto Function
Purpose
Key Takeaways
Last updated
