// Security
MariaDB Security
ระบบ Security ครบวงจรของ MariaDB — Authentication Plugins, Roles, SSL/TLS และ Data-at-Rest Encryption
// Authentication
Authentication Plugins
🔌 Pluggable Authentication
MariaDB รองรับ Authentication Plugins หลายแบบ — mysql_native_password, ed25519, PAM, GSSAPI/Kerberos, Unix socket และ LDAP (Enterprise)
-- สร้าง User ด้วย ed25519 (modern, secure)
CREATE USER "app_user"@"10.0.0.%"
IDENTIFIED VIA ed25519 USING PASSWORD("StrongPass!123");
-- สร้าง Role และ assign
CREATE ROLE app_readonly;
GRANT SELECT ON mydb.* TO app_readonly;
GRANT app_readonly TO "app_user"@"10.0.0.%";
-- SSL requirement
GRANT ALL ON mydb.* TO "secure_user"@"%"
REQUIRE SSL;
// Encryption
Data-at-Rest Encryption
🔐 Table Encryption (Free!)
MariaDB 10.1+ รองรับ per-table/per-tablespace encryption ด้วย AES ฟรี ไม่ต้องใช้ Enterprise edition เหมือน MySQL
# เปิด encryption ใน my.cnf
plugin_load_add = file_key_management
file_key_management_filename = /etc/mysql/encryption/keyfile
innodb_encrypt_tables = ON
innodb_encrypt_log = ON
-- สร้าง Encrypted Table
CREATE TABLE sensitive_data (
id INT AUTO_INCREMENT PRIMARY KEY,
data TEXT
) ENCRYPTED=YES;