Lab 18: Database Security
Step 1 — MySQL: CREATE USER and Password Policies
-- Create users with strong passwords
CREATE USER 'app_user'@'%' IDENTIFIED BY 'AppPass123!';
CREATE USER 'readonly_user'@'%' IDENTIFIED BY 'ReadOnly123!';
CREATE USER 'report_user'@'localhost' IDENTIFIED BY 'Report123!';
-- Require SSL connection
CREATE USER 'secure_user'@'%'
IDENTIFIED BY 'SecurePass123!'
REQUIRE SSL;
-- Password policy: expire after 90 days
CREATE USER 'audit_user'@'%'
IDENTIFIED BY 'AuditPass123!'
PASSWORD EXPIRE INTERVAL 90 DAY;
-- View users
SELECT user, host, plugin, account_locked, password_expired
FROM mysql.user
WHERE user NOT IN ('root','mysql.sys','mysql.infoschema','mysql.session');Step 2 — MySQL: GRANT and REVOKE
Step 3 — MySQL 8: Roles
Step 4 — PostgreSQL: CREATE ROLE and GRANT
Step 5 — PostgreSQL: Row-Level Security (RLS)
Step 6 — PostgreSQL: Column-Level Security
Step 7 — pg_hba.conf and SSL Concepts
Method
Description
Step 8 — Capstone: Secure Multi-Tenant Database
Summary
Feature
MySQL
PostgreSQL
Last updated
