> For the complete documentation index, see [llms.txt](https://docs.tessell.com/tessell/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tessell.com/tessell/database-engines/tessell-for-mysql/configure-ssl-tls-connection-to-tessell-mysql.md).

# Configure an SSL/TLS Connection to Tessell MySQL

Download the CA certificate, create an SSL-only MySQL user, connect with certificate and hostname verification, and troubleshoot SSL/TLS connections to your Tessell MySQL service.

Tessell MySQL supports SSL/TLS-encrypted connections between client applications and the database service. SSL/TLS protects data in transit from being read or modified between the client and the database.

This guide covers how to:

1. Download the CA certificate from the Tessell Console.
2. Create a MySQL user that requires SSL/TLS.
3. Connect securely using the MySQL command-line client.
4. Verify that the connection is encrypted.
5. Handle hostname verification over PrivateLink and troubleshoot common errors.

> **Note:** Configuring SSL/TLS in application drivers (JDBC, ODBC, Python, Go, and so on) is beyond the scope of this guide. The same concepts apply — supply the CA certificate and choose a verification mode. Refer to your driver's documentation for driver-specific options.

***

## Prerequisites

* A running Tessell MySQL DB service with **SSL** enabled. SSL is enabled in the **Connectivity** settings at provisioning time — see [Provisioning a MySQL service](https://docs.tessell.com/tessell/database-engines/tessell-for-mysql/db-services/provisioning-a-mysql-service.md). If SSL was not enabled for your service, contact Tessell Support.
* Network connectivity from the client machine to the database host and port (default **3306**). Your client IP or CIDR must be listed under **Allowed IP addresses** on the service's **Overview** tab.
* The connection details from the service's **Overview** tab: **Host**, **Port**, **Database**, and **Username**. See [Overview](https://docs.tessell.com/tessell/database-engines/tessell-for-mysql/db-services/readme-mysql/homepage-mysql/overview-mysql.md).
* A MySQL client installed on the client machine. MySQL client 8.0 or later is recommended.
* A MySQL administrative account with privileges to create users and grant permissions.

***

## Step 1 — Download the CA certificate

The CA certificate lets the client verify that the certificate presented by the MySQL server was issued by a trusted authority.

1. **Sign in** to the Tessell Console.
2. From the left navigation pane, go to **DB Services** and open the **My Services** app.
3. Select your MySQL DB service.
4. On the **Overview** tab, locate the **CA certificate** section.
5. Download the CA certificate.
6. Copy the certificate to the client machine from which you will connect.

Save the certificate in a dedicated directory on the client machine. For example:

```bash
mkdir -p ~/mysql-certs
chmod 700 ~/mysql-certs
# Copy the downloaded certificate into this directory, e.g. as TessellCA.crt
```

Verify that the certificate exists, is readable, and is within its validity period:

```bash
ls -l ~/mysql-certs/TessellCA.crt
openssl x509 -in ~/mysql-certs/TessellCA.crt -noout -subject -issuer -dates
```

> **Note:** The CA certificate is public trust material, not a private key. You do not need to modify any server-side certificate or key files to configure a client connection.

***

## Step 2 — Create a MySQL user that requires SSL

Connect to the database using an administrative account, then create a dedicated application user that can only connect over an encrypted connection:

```sql
CREATE USER 'ssl_user'@'%'
  IDENTIFIED BY '<strong-password>'
  REQUIRE SSL;
```

Grant the user only the privileges the application needs:

```sql
GRANT SELECT, INSERT, UPDATE, DELETE
  ON <database_name>.*
  TO 'ssl_user'@'%';
```

> **Important:** The host pattern `%` allows connections from any host and is used here for illustration only. In production, restrict the account to the specific client host or network range where practical (for example, `'ssl_user'@'10.0.1.%'`).

#### What does `REQUIRE SSL` do?

`REQUIRE SSL` allows the account to connect only over an encrypted connection. A connection attempt without encryption is rejected with an `Access denied` error. It does **not** require the client to present its own X.509 client certificate.

To enforce SSL for an existing user:

```sql
ALTER USER 'ssl_user'@'%' REQUIRE SSL;
```

Verify the account configuration:

```sql
SHOW CREATE USER 'ssl_user'@'%';
SHOW GRANTS FOR 'ssl_user'@'%';
```

The output of `SHOW CREATE USER` includes `REQUIRE SSL` when the requirement is in effect.

For more information, see the MySQL documentation for [CREATE USER](https://dev.mysql.com/doc/refman/8.0/en/create-user.html).

***

## Step 3 — Connect using the MySQL command-line client

Use the **Host** value from the service's **Overview** tab for `<tessell-mysql-host>`. For HA services, Tessell keeps this hostname pointed at the current primary, so always connect using it.

The `--ssl-mode` option controls how strictly the client enforces and verifies SSL/TLS:

| `--ssl-mode`                 | Encrypts traffic          | Verifies CA | Verifies hostname | Recommended use                                           |
| ---------------------------- | ------------------------- | ----------- | ----------------- | --------------------------------------------------------- |
| `PREFERRED` (client default) | If the server supports it | No          | No                | Not recommended — silently falls back to unencrypted      |
| `REQUIRED`                   | Yes                       | No          | No                | Basic testing only                                        |
| `VERIFY_CA`                  | Yes                       | Yes         | No                | When the connection hostname cannot match the certificate |
| `VERIFY_IDENTITY`            | Yes                       | Yes         | Yes               | **Production**                                            |

### Option A — Require encryption

```bash
mysql \
  --host=<tessell-mysql-host> \
  --port=3306 \
  --user=ssl_user \
  --password \
  --ssl-mode=REQUIRED
```

Enter the password when prompted. This mode guarantees encryption but does not verify the server's identity, so it does not protect against an impersonated server.

### Option B — Verify the CA certificate

```bash
mysql \
  --host=<tessell-mysql-host> \
  --port=3306 \
  --user=ssl_user \
  --password \
  --ssl-mode=VERIFY_CA \
  --ssl-ca=$HOME/mysql-certs/TessellCA.crt
```

This mode requires encryption and validates the server certificate against the Tessell CA certificate.

### Option C — Verify the CA and server hostname (recommended)

```bash
mysql \
  --host=<tessell-mysql-host> \
  --port=3306 \
  --user=ssl_user \
  --password \
  --ssl-mode=VERIFY_IDENTITY \
  --ssl-ca=$HOME/mysql-certs/TessellCA.crt
```

This mode validates the certificate chain **and** checks that the hostname passed in `--host` matches the identity in the server certificate.

> **Recommendation:** Use `VERIFY_IDENTITY` for production connections. If you get any error, please see [Troubleshooting](#troubleshooting).

***

## Step 4 — Verify the SSL/TLS connection

After connecting, run:

```sql
SHOW SESSION STATUS LIKE 'Ssl_cipher';
SHOW SESSION STATUS LIKE 'Ssl_version';
```

Example output:

```
+---------------+------------------------+
| Variable_name | Value                  |
+---------------+------------------------+
| Ssl_cipher    | TLS_AES_256_GCM_SHA384 |
+---------------+------------------------+

+---------------+---------+
| Variable_name | Value   |
+---------------+---------+
| Ssl_version   | TLSv1.3 |
+---------------+---------+
```

* A non-empty `Ssl_cipher` value confirms that the current session is encrypted.
* `Ssl_version` shows the TLS protocol version in use.
* An empty value means the current session is **not** encrypted.

The exact cipher and TLS version depend on the server and client versions and configuration.

You can also run `\s` (or `status`) in the MySQL client. The `SSL:` line shows the cipher in use, or `Not in use` if the session is unencrypted.

***

## Server-level secure transport setting

MySQL also has a server-level variable, `require_secure_transport`. Check its current value:

```sql
SHOW VARIABLES LIKE 'require_secure_transport';
```

When this variable is `ON`, the server rejects all unencrypted TCP connections, regardless of whether an individual account has `REQUIRE SSL`.

| Control                       | Scope                         | How it is set                               |
| ----------------------------- | ----------------------------- | ------------------------------------------- |
| `REQUIRE SSL`                 | A specific MySQL account      | `CREATE USER` / `ALTER USER`                |
| `require_secure_transport=ON` | All connections to the server | Server configuration (DB parameter profile) |

On Tessell, server parameters are managed through the service's DB parameter profile. Review your service configuration and organizational policies before changing server-level settings, and contact Tessell Support if you need assistance.

For more information, see the MySQL documentation for [Configuring MySQL to Use Encrypted Connections](https://dev.mysql.com/doc/refman/8.0/en/using-encrypted-connections.html).

***

## PrivateLink endpoints and hostname verification

When a client connects through a PrivateLink endpoint, the hostname the client uses may differ from the hostname in the server certificate. For example:

* Server certificate identity: `<service-name>.<tessell-domain>`
* Hostname used by the application: a cloud VPC endpoint DNS name

With `--ssl-mode=VERIFY_IDENTITY`, the hostname passed to the client must match a name in the server certificate's hostname. If it does not, the connection fails with a hostname mismatch — even when the CA certificate is correct.

To resolve this:

1. Confirm the exact hostname the application uses to connect.
2. Inspect the SAN entries of the server certificate (requires OpenSSL 1.1.1 or later):

   ```bash
   openssl s_client -connect <hostname>:3306 -starttls mysql </dev/null 2>/dev/null \
     | openssl x509 -noout -ext subjectAltName
   ```
3. Check whether the hostname used by application appears in the output of previous command.
4. If it does not, contact Tessell Support to align the PrivateLink endpoint DNS and certificate configuration — for example, PrivateLink DNS name matches with the DNS name in the certificate.
5. Retest the connection with `--ssl-mode=VERIFY_IDENTITY`.

> **Warning:** Do not disable hostname verification as a permanent workaround for a hostname mismatch. If you must use `VERIFY_CA` temporarily, track it as a known gap and return to `VERIFY_IDENTITY` once the configuration is corrected.

***

## Troubleshooting

| Error or symptom                                                                                                   | Possible cause                                                                                                                                     | Recommended action                                                                                                                                                                                                                                                                               |
| ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `ERROR 1045 (28000): Access denied for user`                                                                       | Incorrect credentials, host pattern mismatch, or the account has `REQUIRE SSL` but the connection is unencrypted                                   | Verify the password and account host pattern. Connect with `--ssl-mode=REQUIRED` or stronger.                                                                                                                                                                                                    |
| `ERROR 3159 (HY000): Connections using insecure transport are prohibited while --require_secure_transport=ON`      | The server requires secure transport, but the connection is not encrypted                                                                          | Connect with `--ssl-mode=REQUIRED` or stronger.                                                                                                                                                                                                                                                  |
| `ERROR 2026 (HY000): SSL connection error: CA certificate is required if ssl-mode is VERIFY_CA or VERIFY_IDENTITY` | `--ssl-mode=VERIFY_CA` or `VERIFY_IDENTITY` was used without `--ssl-ca`                                                                            | Add `--ssl-ca=<path-to-CA-certificate>`.                                                                                                                                                                                                                                                         |
| `ERROR 2026 (HY000): SSL connection error: ... certificate verify failed`                                          | Wrong CA certificate, expired certificate, or incorrect `--ssl-ca` path. The `--host` value does not match with hostname in the server certificate | Download the current CA certificate from the **Overview** tab and check its validity with `openssl x509 -dates`. Connect using the **Host** from the **Overview** tab. For PrivateLink, see [PrivateLink endpoints and hostname verification](#privatelink-endpoints-and-hostname-verification). |
| `Ssl_cipher` is empty                                                                                              | The session is not encrypted (client used `PREFERRED` or `DISABLED`)                                                                               | Reconnect with an explicit `--ssl-mode` of `REQUIRED` or stronger and recheck.                                                                                                                                                                                                                   |

***

## Production readiness checklist

Before using SSL/TLS for an application in production:

* [ ] SSL is enabled on the Tessell MySQL service.
* [ ] The correct, current CA certificate is downloaded from the **Overview** tab.
* [ ] The application user is created or updated with `REQUIRE SSL`.
* [ ] The application user has only the privileges it needs, with a restricted host pattern.
* [ ] Connections are tested with `VERIFY_IDENTITY` (or `VERIFY_CA` where hostname verification is not yet possible).
* [ ] `Ssl_cipher` and `Ssl_version` are confirmed for a test session.
* [ ] Hostname verification is validated for PrivateLink endpoints, if used.
* [ ] Application drivers are configured with the CA certificate and an equivalent verification mode.
* [ ] Application connectivity is tested before production use case.

***

## References

* Tessell — [Overview tab (connection details and CA certificate)](https://docs.tessell.com/tessell/database-engines/tessell-for-mysql/db-services/readme-mysql/homepage-mysql/overview-mysql.md)
* Tessell — [Provisioning a MySQL service](https://docs.tessell.com/tessell/database-engines/tessell-for-mysql/db-services/provisioning-a-mysql-service.md)
* Tessell Help Center — [How are SSL certificates configured for databases?](https://help.tessell.com/en/articles/9000495-how-are-ssl-certificates-configured-for-databases)
* MySQL 8.0 — [CREATE USER Statement](https://dev.mysql.com/doc/refman/8.0/en/create-user.html)
* MySQL 8.0 — [Configuring MySQL to Use Encrypted Connections](https://dev.mysql.com/doc/refman/8.0/en/using-encrypted-connections.html)
* MySQL 8.0 — [Command Options for Encrypted Connections](https://dev.mysql.com/doc/refman/8.0/en/connection-options.html#encrypted-connection-options)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tessell.com/tessell/database-engines/tessell-for-mysql/configure-ssl-tls-connection-to-tessell-mysql.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
