DataSunrise Achieves AWS DevOps Competency Status in AWS DevSecOps and Monitoring, Logging, Performance

How to Ensure Data Governance for TiDB

How to Ensure Data Governance for TiDB

TiDB is a distributed SQL database built for hybrid transactional and analytical processing (HTAP). It’s fast, horizontally scalable, and MySQL-compatible — but when it comes to enterprise-grade data governance, it needs a boost.

Data governance refers to the framework of policies, controls, and technologies that ensure data is secure, accurate, accessible, and compliant throughout its lifecycle. It includes managing user access, tracking changes, protecting sensitive information, and meeting regulatory obligations like GDPR, HIPAA, and SOX.

This guide shows how to apply governance to TiDB using its native tools and how to close the gaps with DataSunrise, a full-featured compliance and database security platform.

Why TiDB Needs Governance

Whether you’re storing customer records, financial transactions, or health data, governance ensures your database meets requirements for:

  • Access control
  • Auditability
  • Sensitive data protection
  • Regulatory compliance

TiDB provides foundational controls — but they’re often limited, manual, or missing altogether. Let’s start with what’s built-in.

Native TiDB Governance Tools

Role-Based Access Control

TiDB includes role management compatible with MySQL syntax. You can create roles and delegate access privileges like this:

CREATE ROLE 'compliance_auditor';
GRANT SELECT ON hr_data.* TO 'compliance_auditor';
GRANT 'compliance_auditor' TO 'alice'@'%';

See the official documentation on roles and grants for more.

Audit Logging (Enterprise & Cloud Dedicated)

Available in TiDB v7.1+ Enterprise and Dedicated Cloud tiers. You can filter what gets logged, redact SQL, and assign rules to users:

SET GLOBAL tidb_audit_enabled = 1;

CALL audit_log_create_filter('login_attempts', '{
  "filter": [
    { "class": ["CONNECT"], "status_code": [0] },
    { "class": ["QUERY_DDL"] }
  ]
}');

CALL audit_log_create_rule('login_attempts', 'admin@%', true);

SET GLOBAL tidb_audit_log_redacted = ON;

Full configuration instructions are available in the TiDB Audit Logging Guide (PDF).

Cluster-Wide Log Search

Search audit logs across TiDB, TiKV, and PD nodes:

SELECT * FROM information_schema.cluster_log
WHERE message LIKE '%ddl%'
  AND time > NOW() - INTERVAL 30 MINUTE;

Field definitions and usage examples are covered in the CLUSTER_LOG documentation.

Point-in-Time Recovery (PITR)

TiDB’s BR tool supports PITR from log backups:

tiup br log start --task-name=pitr \
  --pd="${PD_IP}:2379" \
  --storage 's3://mybucket/logs'

tiup br restore point \
  --restored-ts '2025-07-10 12:00:00' \
  --pd="${PD_IP}:2379" \
  --storage 's3://mybucket/logs'

Read more in the TiDB PITR documentation.

Manual Data Discovery (Regex Queries)

SELECT table_name, column_name
FROM information_schema.columns
WHERE column_name REGEXP 'email|name|card|phone';
DBeaver interface showing manual sensitive data discovery in TiDB, listing varchar columns like first_name, email, and phone1 from the pii_customers table.
Manual sensitive data discovery in TiDB using DBeaver. The `pii_customers` table contains fields such as first_name, last_name, phone1, and email — all marked as varchar, suggesting potential PII columns for classification or masking.

Useful, but limited — there’s no built-in classification, tagging, or mapping to compliance standards.

Where Native Features Fall Short

FeatureCommunityEnterprise/Dedicated CloudNotes
RBACBasic SQL grants
Structured Audit Logs✅ (v7.1+)JSON filters, no GUI
Redacted LoggingManual toggle
Dynamic MaskingNot supported
Data DiscoveryManualManualRegex only, no tagging or dashboards
Real-Time AlertsExternal tooling required
Compliance ReportsNot available natively

Extending Governance with DataSunrise

DataSunrise is a database security platform that integrates seamlessly with TiDB. It operates as a proxy or sniffer layer, inspecting traffic and applying compliance rules in real time—without requiring changes to your database or application logic.

It offers discovery, masking, auditing, and alerting features that close the compliance gaps left by native tools.

Sensitive Data Discovery

Unlike regex-based methods, DataSunrise includes a built-in engine for classifying columns by content and context. Its discovery module automatically detects PII, PHI, and financial data using preconfigured patterns aligned with major regulations.

You get schema-wide dashboards that highlight sensitive data across your TiDB environment.

DataSunrise interface showing compliance scan statistics for TiDB, including scanned databases, schemas, and columns with breakdown of 12 detected information types such as names, credit cards, and phone numbers.
DataSunrise compliance discovery results for a TiDB instance. The scan identified 24 sensitive columns across two tables and classified them into 12 information types, including names, credit card numbers, and telephone formats.

Dynamic Data Masking

DataSunrise enables column-level masking based on who’s querying the database, what they’re accessing, and how. With masking rules, you can define:

  • Full or partial masking
  • Hashing, nulling, or regex substitution
  • Rules based on user, IP, or schema context

It all happens before the query reaches TiDB.

Real-Time Alerts and Monitoring

Configure alerts for sensitive events like:

  • Failed logins
  • DDL changes
  • Large query volumes

You can integrate with Slack, Microsoft Teams, email, or your SIEM via notification rules.

Compliance Reporting

DataSunrise makes audit output actionable with exportable PDF and CSV reports covering:

  • Access logs
  • Masking rule usage
  • Classification summaries

These reports align with regulator expectations for GDPR, HIPAA, and SOX audits.

Visual Rule Management

Teams can define and manage governance policies through an intuitive UI, building and assigning rules without writing code. This makes it easier to scale governance efforts across teams and databases.

How to Apply Data Governance for TiDB - DataSunrise interface showing audit rule configuration for TiDB, with filters applied to specific users and SQL event types
The Audit Rules screen in DataSunrise, showing applied filters that target specific users and SQL events. These rules help enforce auditing policies across TiDB instances with no-code configuration.

Architecture: Governance with DataSunrise and TiDB

To implement policy enforcement without changing your application logic or modifying TiDB internals, DataSunrise operates as a transparent proxy. It intercepts SQL queries, applies masking, logging, or alerting rules, and then passes them to TiDB as usual.

The diagram below illustrates how DataSunrise fits into the TiDB deployment model:

Architecture diagram showing how DataSunrise sits as a proxy layer between applications and the TiDB cluster, handling audit, masking, discovery, and alerting.
Data governance architecture using DataSunrise as a transparent enforcement layer in front of TiDB.

Governance Task Checklist

To help apply these practices step-by-step, here’s a quick breakdown of essential governance tasks and the tools best suited for each.

TaskToolDescription
Define roles & accessTiDBUse CREATE ROLE, GRANT
Set up audit filtersTiDB EnterpriseJSON-based, filtered by event class
Enable PITRTiDB BRLog-based restore to a precise timestamp
Discover sensitive dataDataSunriseAuto-scan and classify columns
Mask data dynamicallyDataSunriseBased on user, IP, schema, or role
Send real-time alertsDataSunriseSlack, Teams, email, SIEM
Generate audit reportsDataSunriseExport compliance data in CSV or PDF

Conclusion

TiDB offers strong foundational tools for access control and backup, but its governance features stop short of what modern compliance demands.

DataSunrise fills that gap with dynamic enforcement, automated classification, real-time alerting, and policy-based visibility — all without modifying your applications or database structure.

For teams seeking to implement full lifecycle governance in TiDB, it’s the practical, efficient path forward.

Protect Your Data with DataSunrise

Secure your data across every layer with DataSunrise. Detect threats in real time with Activity Monitoring, Data Masking, and Database Firewall. Enforce Data Compliance, discover sensitive data, and protect workloads across 50+ supported cloud, on-prem, and AI system data source integrations.

Start protecting your critical data today

Request a Demo Download Now

Next

IBM Netezza Audit Tools

IBM Netezza Audit Tools

Learn More

Need Our Support Team Help?

Our experts will be glad to answer your questions.

General information:
[email protected]
Customer Service and Technical Support:
support.datasunrise.com
Partnership and Alliance Inquiries:
[email protected]