Database access: PostgreSQL, MySQL, SQL Server, Redis and MongoDB
People use their own database client (psql, mysql, sqlcmd, redis-cli, mongosh, DBeaver, SSMS...) against a Captivo address. Captivo signs in to the database for them with a saved account the user never sees, logs every statement, and ends the connection when access ends.
How it works
A database resource sits behind a Connector in your network, like any other resource. The difference is the last mile: instead of a page in the browser, the person gets a short-lived connection ticket and points a normal client at Captivo's database proxy.
- The admin saves the database server and an account for it in the resource. The password is sealed to the Connector and is never shown to anyone again.
- The person opens My access, presses Connect on the database and gets a ticket: 24 characters, for example
k7m2x9qp4tbn8dcv3wzr5hya. - The client connects to the proxy on the console's address with the ticket as the user name (or password, see below). The proxy checks the ticket and the person's access, the Connector signs in to the real server with the saved account, and from then on the proxy relays the traffic and logs it.
The ticket is valid for at most eight hours, never past the end of the person's grant, and it ends when the browser sign-in that asked for it ends: signing out of Captivo closes the ticket and its connections. Access is checked again at every new connection and every minute; a grant that ends, a disabled user or a vendor outside the IP allowlist closes the session. Tickets are stored hashed.
Before you start
- A running Connector that can reach the database server. Minimum Connector version per engine: PostgreSQL 2.46.0, MySQL / MariaDB 2.51.0, SQL Server 2.56.0, Redis and MongoDB 2.64.0, a database user per connection 2.70.0. The console warns in the form when the Connector is too old, and people see a disabled Connect button.
- If you set
ALLOWED_TARGETSon the Connector, the database'shost:portmust be on the list. - A database account for Captivo to sign in with. Create it for this purpose and give it only the rights people should have (see the read-only section below).
Define a database resource
Go to Infrastructure → Resources → Add resource, pick the Database kind and choose the engine. General resource fields (name, connector or connector group, grants) work as in Resources. The database-specific ones:
| Field | What to enter |
|---|---|
| Engine | PostgreSQL, MySQL / MariaDB, SQL Server, Redis or MongoDB. MariaDB uses the MySQL option. |
| Address and port | The server as the Connector sees it, for example db01.corp.example:5432. The usual port of the engine is used if you leave it out (5432, 3306, 1433, 6379, 27017). |
| Username / password | The saved account, for example app_readonly. Users never see these; they are sealed to the Connector (to every member of a connector group). Changing the address, user name or connector means entering the password again. |
| Default database | PostgreSQL: required (for example crm); the database a client lands in when it names none. MySQL and SQL Server: optional, the account's own default applies. For Redis the same field is Database number (0); for MongoDB it is Authentication database (admin when empty). |
| Allowed databases | PostgreSQL only, optional, up to 50 names (no spaces or quotes, at most 63 characters). With a list only those databases open; without one, any the account can open. Other engines have no list: a statement can name another database (crm.orders), so the account's own grants decide. |
| Session role | PostgreSQL and MySQL / MariaDB, optional: a database user per connection, see below. |
| TLS from the connector to the server | Encrypted (default; does not check the server's certificate, fine for a self-signed one inside your network), Encrypted + verified (the certificate must name the address and chain to the CA you paste, or the system's CA if empty) or Off. With Off on SQL Server only the sign-in packet is encrypted; on Redis the password crosses your network in the clear. A resource with TLS Off shows a warning chip. |
| Query log | On by default for a new database resource. See the query log section. |
Then grant people access exactly as for any resource, in Access → New grant, or let them request it. Approval, schedules, ticket gates and access reviews apply unchanged. Vendor access, Access reviews and ticketing.
Proxy ports and the certificate
Each engine has its own port on the console's host name. The portal shows the exact host and port in Connect, so people never have to remember them. Your firewall in front of the console must allow the port of every engine you use.
| Engine | Cloud | Self-hosted (default) | Setting to change it |
|---|---|---|---|
| PostgreSQL | 15432 | 15432 | DB_PUBLIC_PORT |
| MySQL / MariaDB | 13307 | 13306 | MYSQL_PUBLIC_PORT |
| SQL Server | 11433 | 11433 | MSSQL_PUBLIC_PORT |
| Redis | 16380 | 16380 | REDIS_PUBLIC_PORT |
| MongoDB | 17017 | 17017 | MONGODB_PUBLIC_PORT |
deploy/docker-compose.prod.yml. *_PUBLIC_PORT on the manager changes the port shown to people (set it with the compose mapping), DB_PUBLIC_HOST changes the host name shown, and DB_ADDR=off, MYSQL_ADDR=off, MSSQL_ADDR=off, REDIS_ADDR=off or MONGO_ADDR=off on the data plane turns one proxy off (the Connect button then says database connections are not set up). Without DB_TLS_CERT and DB_TLS_KEY the proxy keeps a self-signed certificate in the data plane's /data volume: sslmode=require and --ssl-mode=REQUIRED accept it, verify-full does not, and SQL Server clients need Trust server certificate. Point those two variables at the console's own certificate to let clients verify. See Access on your own server.TLS from the client to the proxy is always required; plaintext connections are refused. SQL Server's proxy speaks TLS 1.2 only.
How a vendor connects
In My access the vendor presses Connect on the database. The window offers the command line, the fields for GUI tools and a URL, each with a copy button, and the time the details stay valid (“Opens connections until ...”). Connections that were already open keep running after the ticket expires, for as long as the access lasts; press Get new details for a new one. The ticket is personal: it should not be shared or kept for long.
The ticket goes where the user name goes. Engines whose clients insist on a password get any value, written x below. The examples use the host acme.cloud.captivo.io and the sample ticket k7m2x9qp4tbn8dcv3wzr5hya.
PostgreSQL
# password: leave it empty (press Enter if asked)
psql "host=acme.cloud.captivo.io port=15432 user=k7m2x9qp4tbn8dcv3wzr5hya dbname=crm sslmode=require"
# URL form (DBeaver, DataGrip, pgAdmin, application drivers)
postgresql://k7m2x9qp4tbn8dcv3wzr5hya@acme.cloud.captivo.io:15432/crm?sslmode=require
jdbc:postgresql://acme.cloud.captivo.io:15432/crm?sslmode=require&user=k7m2x9qp4tbn8dcv3wzr5hyaMySQL / MariaDB
# password: leave it empty
mysql -h acme.cloud.captivo.io -P 13307 -u k7m2x9qp4tbn8dcv3wzr5hya --ssl-mode=REQUIRED crm
# MariaDB's client takes --ssl instead of --ssl-mode=REQUIRED
mariadb -h acme.cloud.captivo.io -P 13307 -u k7m2x9qp4tbn8dcv3wzr5hya --ssl crm
mysql://k7m2x9qp4tbn8dcv3wzr5hya@acme.cloud.captivo.io:13307/crm?ssl-mode=REQUIRED
jdbc:mysql://acme.cloud.captivo.io:13307/crm?sslMode=REQUIRED&user=k7m2x9qp4tbn8dcv3wzr5hyaAt connect the client sees the version 8.0.36-Captivo-Access, because the proxy greets it before it knows the server; SELECT VERSION() returns the real one.
SQL Server
# any password; the ticket is the login
sqlcmd -S tcp:acme.cloud.captivo.io,11433 -U k7m2x9qp4tbn8dcv3wzr5hya -P x -d CRM
Server=tcp:acme.cloud.captivo.io,11433;Database=CRM;User ID=k7m2x9qp4tbn8dcv3wzr5hya;Password=x;Encrypt=True
jdbc:sqlserver://acme.cloud.captivo.io:11433;databaseName=CRM;user=k7m2x9qp4tbn8dcv3wzr5hya;password=x;encrypt=trueIn SSMS, Azure Data Studio or DBeaver: Server name acme.cloud.captivo.io,11433; Authentication SQL Server Authentication; Login = the ticket; Password = x; Encryption Mandatory (not Strict). Windows and Entra ID sign-in, and MARS, are not offered.
Redis
# Redis 6+: the ticket is the user name, any password
redis-cli --tls -h acme.cloud.captivo.io -p 16380 --user k7m2x9qp4tbn8dcv3wzr5hya --pass x
# Redis before 6 (password-only clients): the ticket is the password
rediss://k7m2x9qp4tbn8dcv3wzr5hya:x@acme.cloud.captivo.io:16380TLS must be on. The proxy speaks RESP2: a client that asks for RESP3 (HELLO 3) is told to fall back, which every common client does.
MongoDB
mongosh "mongodb://k7m2x9qp4tbn8dcv3wzr5hya:x@acme.cloud.captivo.io:17017/?tls=true&authMechanism=PLAIN&authSource=%24external"The connection string has to ask for authMechanism=PLAIN, authSource=$external and TLS: that is how the ticket is passed. A client left on its default sign-in (SCRAM) is refused and told what to change. In Compass or Studio 3T pick Username / Password, mechanism PLAIN, authentication database $external, TLS on.
Read-only or write: the account decides
There is no read-only switch on a database resource, on purpose. The proxy does not parse statements to block writes: that is easy to get around and gives false comfort. What a session can do is exactly what the saved account can do. For read-only access save an account that can only read; for write access save one that can write. Use two resources (and two grants) when some people need each.
-- PostgreSQL: a read-only account for the crm database
CREATE ROLE captivo_ro LOGIN PASSWORD '<strong password>';
GRANT CONNECT ON DATABASE crm TO captivo_ro;
GRANT USAGE ON SCHEMA public TO captivo_ro;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO captivo_ro;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO captivo_ro;
-- MySQL / MariaDB
CREATE USER 'captivo_ro'@'%' IDENTIFIED BY '<strong password>';
GRANT SELECT ON crm.* TO 'captivo_ro'@'%';
-- Redis (redis.conf / ACL): only read commands, only keys under cart:
ACL SETUSER captivo_ro on >'<strong password>' ~cart:* +@read -@dangerous
-- MongoDB (run in the admin database)
db.createUser({ user: "captivo_ro", pwd: "<strong password>", roles: [{ role: "read", db: "shop" }] })Statements worth a second look are marked in the query log, as a hint for the reviewer, never as a control. The proxy does refuse a few Redis and MongoDB commands that would hand out the saved password or change the server itself: see limits.
A database user per connection
For PostgreSQL and MySQL / MariaDB you can fill Session role (for example app_readonly). The saved account then only provisions: for every connection a person opens, the Connector signs in as the saved account, creates a user named captivo_tmp_<time>_<random> with a random password that inherits the role, signs in as it, and drops it when the connection closes. The client works with exactly the role's rights, and the server's own log and pg_stat_activity show a user that exists for that connection only; Captivo's query log says who it was.
- Nothing is left standing: the password exists only inside the Connector for the length of the connection, PostgreSQL stamps the user
VALID UNTILten minutes ahead, and a user a crash left behind is dropped by the next connection once it is six hours old. - One-time setup: the resource form prints the statements to run once for the saved account (PostgreSQL
CREATEROLEandADMIN OPTIONon the role; MySQL 8CREATE USERandROLE_ADMIN; MariaDBCREATE USER, the roleWITH ADMIN OPTIONandUPDATEonmysql.*). The role itself you make withCREATE ROLEandGRANT. - Each connection is one user, so a client that opens a pool makes several. In MySQL a
KILL QUERYfrom a second connection (Ctrl+C in the mysql client) cannot reach another user's thread; PostgreSQL cancel is unaffected. - It cannot be combined with password check-out (there is no shared password to take). Rotating the saved account's own password still works. See Credential lifecycle and Password rotation.
Query log and recording
With Query log on, the proxy reads each statement and stores it on the Connector that carried the session, with its time, duration, row count and error. Nothing is kept in the cloud; recording search finds statements by their text. Results and bind parameter values are never stored, and password literals (PASSWORD '...', IDENTIFIED BY '...') are masked. Values a client writes into the statement text itself (psql and the mysql client do) are part of the statement.
- Reading it. Open the recording of the session: a table with Time, Statement, Database, Took and Rows, filters All, Failed and To review, and a search box. If the Connector is offline the page says the log is intact on it and shows once it is back. Admins also see the statements live on the Sessions page and can end the session.
- To review marks DROP, TRUNCATE, DELETE or UPDATE without WHERE, GRANT/REVOKE, ALTER ROLE or USER,
INTO OUTFILE,COPY ... TO PROGRAM, SQL Serverxp_cmdshell,OPENROWSET,sp_configureand ALTER LOGIN, RedisFLUSHALL/FLUSHDBand MongoDBdrop,dropDatabase,dropIndexes. - Redis and MongoDB log commands, not statements: a Redis command by name and first argument (
GET user:1,HSET cart:7), a MongoDB command by name anddatabase.collection(find shop.orders) with duration, number of documents and the server's error. Values, scripts, filters and documents stay out; a MongoDB update or delete cannot be told from one that matches everything. - Turning it off. Switch Query log off on the resource and its statements are no longer stored. Policy → Session recording → Recording can set Off or Required for every resource, which overrides the toggle.
- Audit. The Audit page marks these rows DB (own database client, through the database proxy); a session ended because the grant or sign-in ended is recorded with the reason
ticket_ended. Audit can be forwarded to your SIEM, see Log forwarding. Retention and playback follow Session recording and live view.
Limits and what the proxy refuses
| Engine | Limit or refusal |
|---|---|
| All | Ticket at most 8 hours and never past the grant or the sign-in. The proxy must be reached on its own port with TLS. The client has 30 seconds to finish the handshake. |
| PostgreSQL | PostgreSQL 17's direct TLS works. A database outside Allowed databases is refused. |
| MySQL / MariaDB | No compression and no LOAD DATA LOCAL. Changing the user on an open connection is refused. MySQL 5.7 builds with OpenSSL 1.0 offer only DHE ciphers, which the Connector does not use: enable ECDHE or set TLS to Off inside the network. |
| SQL Server | SQL Server logins only: no Windows (Kerberos/NTLM), no Entra ID, no MARS, no Strict encryption (TDS 8). |
| Redis | RESP2 only. Refused: AUTH, RESET, CONFIG, DEBUG, SHUTDOWN, MODULE, MIGRATE, MONITOR, SYNC, PSYNC, REPLICAOF, SLAVEOF, FAILOVER, ACL (except WHOAMI and CAT) and CLIENT REPLY (CONFIG GET requirepass would show the saved password). After SUBSCRIBE replies no longer pair with commands, so logging stops for that connection. A client can SELECT another database: the account's ACL decides what it reaches. |
| MongoDB | PLAIN sign-in only. Refused: signing in again, user and role management, shutdown, setParameter, getCmdLineOpts and replica set administration. Compressed messages and legacy opcodes (except the first isMaster) are not relayed. A command can name any database the account has a role in. |
Error messages a client may show, all starting with "Captivo Access:":
this connection ticket is unknown or has expired. Get a new one from My access in your Captivo portal.The ticket was mistyped, expired or the person signed out.your access to this resource is not activeThe grant ended, is outside its schedule, or the user is disabled.this resource can't be opened as a database right now; ask your administratorThe Connector is too old, or the saved password must be entered again.this resource is a MySQL database; connect with a MySQL client(or PostgreSQL, SQL Server, Redis, MongoDB) The ticket was used on the wrong engine's port.database "x" is not open on this resource (allowed: crm, reporting)The name is not in Allowed databases (PostgreSQL, MySQL error 1044).the database refused the saved account: ...The server rejected the saved account: password changed, account locked, or the host does not allow the Connector. Ask an admin to enter the password again.
Common problems
- The Connect button is greyed out. The Connector is older than the engine's minimum version. Update it from Infrastructure → Connectors.
- “Database connections aren't set up on this service yet.” The proxy for that engine is off or has no certificate. On your own server check
DB_ADDRand the other*_ADDRsettings. - “This database's saved account needs to be entered again by an administrator.” The address, user name or connector changed after the password was saved. Open the resource and enter the password.
- The client hangs or the port is unreachable. The firewall in front of the console blocks the engine's proxy port (table above). Test with
nc -vz acme.cloud.captivo.io 15432. - The certificate is not trusted (self-hosted). You use the self-signed default: use
sslmode=require, or give the proxy the console's certificate. - The MySQL client rejects the connection. Use
--ssl-mode=REQUIRED(MariaDB client:--ssl); TLS cannot be off. - MongoDB: authentication failed with SCRAM. Add
authMechanism=PLAIN&authSource=%24external&tls=trueto the string. - The session ended by itself. The ticket ended: the person signed out of Captivo, the grant ended, or a recheck found access gone. Press Get new details.
- Need a service other than these five (any raw TCP port)? Use a TCP tunnel; it is not recorded.
Related topics
For product-wide problems: The connector shows offline · The app does not open · Cannot sign in with a passkey