How to Enable Encryption in Transit in MariaDB

Galaxy Glossary

How do I enable and enforce SSL/TLS encryption in transit for MariaDB?

Encryption in transit secures data exchanged between MariaDB clients and the server by wrapping every packet in SSL/TLS.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

What does “encryption in transit” mean for MariaDB?

Encryption in transit protects data on the wire by forcing MariaDB to use SSL/TLS for every client-server packet, eliminating plaintext snooping risks.

How do I confirm SSL support is compiled in?

Run SHOW VARIABLES LIKE 'have_ssl';. If it returns YES, the server has SSL libraries. A value of DISABLED or NO means you must recompile or install the SSL plugin.

Which server settings enable SSL?

Add ssl-ca, ssl-cert, and ssl-key paths under the [mysqld] section of my.cnf. Restart the instance to activate TLS handshakes.

How do I force specific users to use SSL?

Use REQUIRE SSL in CREATE USER or ALTER USER. Clients that fail the TLS negotiation cannot connect.

Can I check if an active session is encrypted?

Query SELECT ssl_version, ssl_cipher FROM information_schema.processlist WHERE id = CONNECTION_ID();. A non-NULL result confirms an encrypted link.

How do I enforce SSL on application connectors?

Pass connection parameters such as --ssl-ca, --ssl-cert, and --ssl-key (CLI) or their driver-specific equivalents (useSSL=true, requireSSL=true in JDBC).

Does SSL impact query performance?

Expect a 2-5 % CPU overhead during handshakes and encryption. Modern CPUs with AES-NI typically hide the cost in normal workloads.

Best practices for production deployments?

Rotate certificates yearly, prefer TLS v1.2+, disable weak ciphers, and automate certificate distribution with tools such as Vault or cert-manager.

Quick checklist before going live

1) Certificates issued by trusted CA 2) Strong DH parameters 3) Firewall rules allow 3306 only over TLS 4) Monitoring alerts on have_ssl and expired certs.

Why How to Enable Encryption in Transit in MariaDB is important

How to Enable Encryption in Transit in MariaDB Example Usage


-- Customer success dashboard connects with SSL
mysql --host=db.prod --user=report_reader --password --ssl-ca=ca.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem \
      --execute="SELECT c.name, SUM(o.total_amount) AS lifetime_value
                 FROM Customers c
                 JOIN Orders o ON o.customer_id = c.id
                 GROUP BY c.name
                 ORDER BY lifetime_value DESC
                 LIMIT 10;"

How to Enable Encryption in Transit in MariaDB Syntax


# Server configuration (my.cnf)
[mysqld]
ssl-ca   = /etc/ssl/mariadb/ca.pem
ssl-cert = /etc/ssl/mariadb/server-cert.pem
ssl-key  = /etc/ssl/mariadb/server-key.pem

# Create an SSL-only user for the ecommerce reporting app
CREATE USER 'report_reader'@'%' IDENTIFIED BY 'S3cureP@ss' REQUIRE SSL;
GRANT SELECT ON ecommerce.* TO 'report_reader'@'%';

# Verify session encryption from psql-like client
SHOW STATUS LIKE 'Ssl_cipher';

Common Mistakes

Frequently Asked Questions (FAQs)

Is self-signed acceptable in production?

Use self-signed only for internal testing. Production should rely on a trusted internal or public CA to avoid MITM risks.

Can I mix encrypted and unencrypted users?

Yes. Accounts without REQUIRE SSL can still connect unencrypted, but doing so creates compliance gaps. Prefer full enforcement.

Does replication also need SSL?

Absolutely. Configure CHANGE MASTER TO MASTER_SSL=1 and provide certificates to protect binlog streams.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.