How to connect your database
Ask DB runs on our server; all you need in your network is a small connector. It opens a secure outbound connection to us by itself — so no public IP, no VPN and no open ports.
A one-minute walkthrough in Ukrainian with subtitles — an English version is on the way.
What you'll need
- A computer or server that can reach your database (Linux, Windows or macOS) — with Docker or without it.
- Outbound internet access on port 443 — same as for a regular website.
- A MySQL / MariaDB or PostgreSQL database.
- 5–10 minutes.
Step 1. Create a read-only user
Optional, but highly recommended: even if something goes wrong, such a user physically can't change anything. Run this in the database as an administrator (use your own password):
-- MySQL / MariaDB CREATE USER 'askdb_readonly'@'%' IDENTIFIED BY 'strong-password'; GRANT SELECT ON your_database.* TO 'askdb_readonly'@'%'; -- PostgreSQL (in the target database) CREATE ROLE askdb_readonly LOGIN PASSWORD 'strong-password'; GRANT USAGE ON SCHEMA public TO askdb_readonly; GRANT SELECT ON ALL TABLES IN SCHEMA public TO askdb_readonly;
GRANT SELECT ON your_database.orders TO … (in PostgreSQL — GRANT SELECT ON orders TO …).
The AI will see only those. In MySQL, instead of '%' it's better to specify the IP of the server running the connector.
In PostgreSQL the AI sees tables from the user's search_path schemas — usually public.
Step 2. Create a connection in Ask DB
- Sign up and confirm your email.
- Add a new connection, pick the database type and the “Via connector” mode.
- You'll see a ready
docker runcommand with your personal token.
Step 3. Start the connector
Copy the command from your account to your server. It looks like this:
docker run -d --name adb-connector --restart unless-stopped \ -e CONNECTOR_TOKEN=adbc_… \ -e GATEWAY_URL=wss://connect.ask-db.com.ua/v1/connect \ -e DB_DSN='mysql://USER:PASSWORD@HOST:3306/DATABASE' \ askdb/connector:latest
Replace USER, PASSWORD, HOST and DATABASE in DB_DSN with your own:
- For PostgreSQL the string is different, and your account shows exactly that one:
postgres://USER:PASSWORD@HOST:5432/DATABASE. If the server requires encryption, append?sslmode=require. - HOST is the database address as seen from this server: an IP or a domain. Not
localhostand not127.0.0.1— inside a container that's the container itself, not your server. If the database runs on the same server, use the server's network IP (hostname -I) and make sure the database listens on it, not only on127.0.0.1(MySQL:bind-address, PostgreSQL:listen_addresses). Or add--network hosttodocker run(Linux) — then127.0.0.1really is your server. connection refusedin the logs (docker logs adb-connector) means nothing listens at that address and port: check HOST and the port.access denied— wrong user or password.i/o timeout— a firewall is in the way.- Special characters in the password must be encoded:
@→%40,#→%23,:→%3A. - The database password stays with you, in the connector settings — it's never sent to our server.
As soon as the connector starts, the page in your account will detect it and show which database and user it connected with.
After a server reboot
The connector comes back on its own (--restart unless-stopped) and reconnects to Ask DB with the same token — nothing to repeat. If you stopped the container by hand, start it with docker start adb-connector. Don't run docker run a second time — the name is taken. If you lost the command or the token, create a new one in the dashboard; the old one stops working.
Without Docker
The connector is a single program with no dependencies. If you don't have Docker, download it for your system from
ask-db.com.ua/download/connector
(checksums are in SHA256SUMS) and pass the same variables as in the docker run command:
# Linux (for ARM — linux-arm64) and macOS on Apple Silicon (darwin-arm64) curl -fLo adb-connector https://ask-db.com.ua/download/connector/latest/adb-connector-linux-amd64 chmod +x adb-connector CONNECTOR_TOKEN=adbc_… \ GATEWAY_URL=wss://connect.ask-db.com.ua/v1/connect \ DB_DSN='mysql://USER:PASSWORD@HOST:3306/DATABASE' \ ./adb-connector # Windows (PowerShell), file adb-connector-windows-amd64.exe $env:CONNECTOR_TOKEN="adbc_…" $env:GATEWAY_URL="wss://connect.ask-db.com.ua/v1/connect" $env:DB_DSN="mysql://USER:PASSWORD@HOST:3306/DATABASE" .\adb-connector-windows-amd64.exe
localhost if the database runs on the same computer.
The connector runs while the terminal window is open; to keep it running, make it a service (systemd, Windows Task Scheduler).
Step 4. Ask your first question
Open the connection's chat and ask something you already know the answer to — it's the easiest way to check the quality. If your data has quirks (“status 3 means a cancelled order”), write them down in “Connection settings → AI knowledge”.
Connector settings
Optional variables, if you need to limit the load on the database:
| Variable | Default | What it does |
|---|---|---|
MAX_ROWS | 1000 | Maximum rows in a response |
QUERY_TIMEOUT_MS | 30000 | Timeout for a single query; a longer query is stopped in the database too |
MAX_CONCURRENT_QUERIES | 4 | How many queries can run in the database at once |
QUERY_LOG_FILE | — | File where the connector logs every query it runs (JSON Lines) |
Useful commands
# view the log: connection, every query run docker logs -f adb-connector # cut off Ask DB's access to the database — instantly docker stop adb-connector
Something's not working?
- The connector stopped right after starting —
docker logs adb-connectorwill have a lineERROR stopped reason=…with a hint on what to fix (usually the token orDB_DSN). - “The connector is online but can't reach the database” — check HOST and whether the database accepts connections from the connector server's address.
- Still stuck? Write to support@ask-db.com.ua or on Telegram @AskDbSupportBot — we'll help you connect.