Database Security and KVKK Technical Measures

We implement the technical measures required in KVKK audits to prevent unlawful access to personal data in databases. We integrate data encryption at rest (TDE), audit logging for personal data access, data masking in production and non-production environments, and the destruction of expired records seamlessly into your production systems.

$ mysql -e "SHOW VARIABLES LIKE 'default_table_encryption'"
default_table_encryption ON
$ mysql -e "SELECT name, email FROM crm.customers LIMIT 1"
A*** Y***** a***@***.com Β· masking active
$ tail -n1 /var/log/mysql/audit.log
{"user":"app@10.0.1.7","db":"crm","cmd":"select"}
$ goarchive archive -c crm.yaml --job customers_expired
βœ“ 12,480 rows verified (SHA256), deleted from source

Implementing the measures required in KVKK audits directly on your database

We implement the database-layer technical security controls required for personal data protection without impacting system performance or daily operations.

Encryption (TDE)

We ensure data is encrypted on disk using TDE (Transparent Data Encryption). By configuring keyring plugins for MySQL and the pg_tde component for PostgreSQL, we enable encryption keys to integrate with and be securely managed by your supported enterprise key management servers.

Audit logging

We ensure all access and queries against personal data stored in the database are logged. By deploying Percona Server audit log for MySQL and pgaudit for PostgreSQL, we configure query-level audit logs to be maintained securely within your database environment.

Data masking

We ensure sensitive personal data in production databases is dynamically masked so it is not displayed in cleartext in query results. For test and staging environments, we configure full anonymization. We deploy Percona Server data masking for MySQL and PostgreSQL Anonymizer for PostgreSQL aligned with your role-based access rules.

Retention and destruction

We ensure personal data past its retention period is verifiably purged from the database along with all dependent child records. For MySQL, we automate periodic archiving and destruction using our open-source tool GoArchive, delivering an auditable and dependable process.

Turkey’s Personal Data Protection Law No. 6698 (KVKK) requires data controllers to take technical and organizational measures to safeguard personal data. In this context, we provide consulting and hands-on engineering support to implement the technical requirements at the database layer.

However, implementing technical database safeguards alone does not ensure overall corporate compliance. Data inventories, consent management, privacy notices, and internal administrative procedures must be completed in tandem by the data controller and legal counsel. In audits, technical questions expect answers directly from the database architecture. Organizations unprepared at the database layer risk non-compliance findings even if all administrative processes are fully established.

Implementing the four core technical controls in the database

Encryption at rest (TDE)

Standard MySQL Community Edition lacks the advanced keyring plugins needed to integrate with enterprise key management servers. Storing encryption keys in a local file on the database host largely defeats the security purpose of encryption. To build a robust TDE architecture that integrates with enterprise key managers (such as HashiCorp Vault), we recommend migrating to the open-source Percona Server for MySQL.

Similarly, standard PostgreSQL does not provide native TDE support. We deliver this capability via pg_tde, which operates as part of the Percona Server for PostgreSQL distribution rather than as an isolated plugin. Consequently, enterprise-grade disk encryption on both MySQL and PostgreSQL typically involves a controlled distribution migration. We manage these migrations on production systems with minimal risk and strict change-management discipline. Version upgrades are covered separately on our MySQL 8.4 migration page.

Audit logging

To document every access to personal data stored in the database during KVKK audits, we establish a query-level audit logging infrastructure. This enables granular and filterable recording of which user accessed personal data, at what timestamp, and with which SQL query.

Because open-source audit plugins are not available in MySQL Community Edition, we configure Percona Server audit log for MySQL and pgaudit for PostgreSQL. Since query contents can themselves contain sensitive values, we also structure log retention policies, secure storage paths, and strict access controls as part of the same security architecture.

Data masking

We address data masking along two fronts: on production databases and across non-production testing environments.

On production systems, we prevent sensitive personal data from being exposed in cleartext when queried by users or roles with restricted privileges (such as support personnel, analytics services, or reporting accounts). We configure appropriate masking models so that unmasked personal records remain visible only to privileged roles.

Simultaneously, we prevent real personal data from proliferating uncontrolled into development, QA, and staging environments. We configure Percona Server data masking functions for MySQL and PostgreSQL Anonymizer for PostgreSQL. This maintains realistic data distributions and test integrity without exposing production personal data.

Retention and destruction

The Regulation on the Deletion, Destruction or Anonymization of Personal Data mandates periodic destruction policies for personal data that has reached the end of its retention period. In database engineering, the primary technical challenge is not executing a simple DELETE statement, but executing it without compromising relational data structure and integrity.

In high-throughput production databases where foreign key (FK) constraints are omitted for performance reasons, deleting a record from a parent table can leave orphaned personal data scattered across related tables. Organizations are then forced to develop custom relational archival and purging routines to clean records consistently across all dependent tables.

On MySQL systems, we solve the archiving and destruction of expired data using our open-source product GoArchive. GoArchive traverses relational dependencies to copy dependent rows to target storage, verifies data receipt, and safely removes them from source tables. This verification step forms the technical basis of the destruction record the Regulation requires. On PostgreSQL and MongoDB, we design retention and purging workflows utilizing native database tools and scheduled maintenance routines.

Technical measures on MongoDB installations

MongoDB environments share the same requirements for encryption, audit logging, access controls, and data destruction. However, standard MongoDB Community Edition does not include native audit logging or encryption at rest. We deliver these security features through the open-source Percona Server for MongoDB distribution. Because it is fully compatible with standard MongoDB, no application-level code modifications are required.

We enforce access control following the principle of least privilege using role-based access. A common vulnerability we encounter in the field is applications connecting to MongoDB with administrative credentials. Without collection-level authorization, audit logs cannot distinguish individual operations. We also enforce TLS encryption across both inter-node replica communications and client connections to protect network traffic.

For retention and destruction, MongoDB’s document model offers operational advantages when related data is embedded inside a single document. Where data is distributed across collections via references, purging expired records consistently requires relational-style dependency planning.

Security and recovery procedures differ based on the backup method in TDE-encrypted databases:

  • Physical backups (XtraBackup, pgBackRest, pg_basebackup): Because raw disk blocks are copied directly, the backup files produced from a TDE-enabled database are automatically encrypted. However, to restore these backups, encryption keys (keyring) must be backed up securely and incorporated into your disaster recovery plan.
  • Logical dumps (mysqldump, pg_dump, mydumper): Because data is retrieved via the SQL client layer, dump files are exported in cleartext. Therefore, logical backup files must be separately encrypted in transit and at rest, with strict storage access controls.

We design the backup and recovery plan for encrypted databases with this distinction in mind: Database Backup and Recovery

Encryption and audit logging configurations must be deployed consistently across all cluster nodes: High Availability and Cluster Solutions

We measure and monitor the performance impact of security extensions and audit logging: Performance Tuning and Monitoring

Frequently asked questions

No. KVKK compliance is not limited to database technical measures alone. The data inventory, privacy notices, consent management, administrative safeguards, and internal organizational procedures are integral parts of compliance. We implement and operate the technical requirements at the database layer. Compliance evaluation remains the responsibility of the data controller and its legal counsel. Rather than providing legal counsel, we implement the technical infrastructure in close coordination with your legal team.

The PostgreSQL core does not include native TDE (Transparent Data Encryption) support. We provide this capability using the pg_tde component, which comes bundled with the Percona Server for PostgreSQL distribution rather than as an isolated plugin. Building an open-source TDE architecture that integrates with enterprise key management servers requires a planned Percona Server distribution migration on both PostgreSQL and standard MySQL Community installations.

No. We operate completely independent of software vendors. The components and community extensions we deploy carry open-source licenses. We install, configure, and integrate these open-source tools into our clients' running systems. Our core service is integration engineering and ongoing operational support.

Operational requirements vary by control. Audit logging and data masking can typically be deployed without system downtime. Disk encryption and distribution migrations require careful planning. By progressing across replica nodes and transferring traffic, we contain potential interruptions within planned maintenance windows. Rather than committing to a downtime figure up front, we define the exact schedule with our clients following a topology review.

Yes. Many projects originate from a single audit finding, most frequently the absence of query audit logs or real production data lingering in test environments. Deploying all four measures at once is not mandatory; we can prioritize and address your organization's most pressing need first.

Which finding did your audit identify?

Let us review your current database installation together to evaluate the scope of work required and turn your priorities into a clear implementation roadmap.

Get in touch