Skip to main content
A MySQL service lets an agent reach a MySQL database during a session, with clients such as mysql. The agent never holds the password: the proxy logs in to the database with the service’s account. The agent reaches the service through infisical agent-vault connect.

Prerequisites

  • The Admin role in your Agent Vault project
  • An access bundle to add the service to
  • A running proxy that can reach the database, and whose HTTP port the agent can reach
  • An account on the database with only the access your agents need, such as a read-only database role

Add a MySQL database

1
In your Agent Vault project, go to Access Bundles. Select your access bundle, then select Add Service. In the Services list, select Create New Service.
2
On the Choose a template panel, select the Databases and More tab, then select MySQL.
3
On the Details step, enter a Name and the server’s details. Select Continue.
4
On the Credential step, set up the account the proxy logs in as. Select Continue.
5
Optionally, on the Hook step, pick the hook that checks each connection to this service. Select Continue.
6
On the Review step, select Add Service.
Next, connect your agent to the service.

Server details

  • Name: The name the agent connects with, as in infisical agent-vault connect orders (lowercase letters, numbers, and hyphens, at most 63 characters)
  • Host: The server’s host name or IP address, as the proxy reaches it, such as orders_db for a Docker Compose service (no scheme, port, path, or variable)
  • Port: The server’s port (defaults to 3306)
  • Database: The database the proxy logs in to (not a variable)
  • TLS: How the proxy connects to the database, described in TLS to the database
A MySQL service starts in its database, but the agent can switch to any other database the account can use, so limit the account’s grants to the databases the agent needs.

TLS to the database

TLS applies only to the connection between the proxy and the database. The connection between the agent’s machine and the proxy always uses TLS.
  • Use TLS (on by default): The proxy connects to the database over TLS
  • Verify Certificate (on by default): The proxy checks the database’s certificate against the system’s trusted certificate authorities, or against the CA certificate you add
  • CA Certificate (optional): The PEM certificate of the authority that signed the database’s certificate, if the database uses a private certificate (for AWS RDS, your region’s bundle, such as us-east-1-bundle.pem)
If you turn Use TLS off, a MySQL service connects without TLS.

Credentials

Enter the account’s Username and Password. To give each member their own account, leave the username, the password, or both to each member, as described in member-provided values. To use a password that several services share, type {{ in Password and select a variable.

Limitations

  • Database logins: MySQL services log in with the mysql_native_password, caching_sha2_password, sha256_password, or ed25519 method
  • MySQL clients need mysql_native_password: The proxy offers the agent’s MySQL client only the mysql_native_password login method, so MySQL 8 and MariaDB clients work, and newer clients built without it (such as the current Homebrew mysql) can’t log in

Troubleshooting

The proxy couldn’t log in to the server. Check that:
  • The service’s Host and Port are reachable from the proxy’s machine
  • The account’s username and password are correct
  • The TLS settings match the database, for example Verify Certificate is off or CA Certificate (optional) is set for a database with a private certificate
The session’s log shows the failed connection as an Error row with the reason, and so does the proxy’s own log.If connect printed a message about the service’s hook, the hook server refused the connection or didn’t give a usable answer. See the hook troubleshooting.
The client was built without the mysql_native_password login method, which the proxy needs. Use a MySQL 8 or MariaDB client.