Connect to a database
此内容尚不支持你的语言。
A connection names a database server or file, the user and how to reach it. Connections belong to the project; their passwords never do: they stay in the system keychain. Connections with passwords in the keychain, TLS and SSH tunnels: Works.
Before you start
Section titled “Before you start”- A server or a file. For a server: host, port, database name and a user with a password. For SQLite or DuckDB: the database file, or a folder to create one in.
- A keychain. On macOS the login keychain, on Windows the Credential Manager, on Linux a running Secret Service (GNOME Keyring or KWallet). Without one, Ferris IDEA refuses to save a password rather than write it to a file.
- For Oracle only: Oracle Instant Client, installed by you. Every other built-in driver ships inside Ferris IDEA; nothing is downloaded when you connect.
Add a connection
Section titled “Add a connection”- Open the Database tool window from the stripe on the right.
- Click + (New Data Source…) in its toolbar, or press ⌘N (CtrlN) in the tree. You can also right-click the tree and choose New › Data Source…. The New Connection dialog opens on its General page.
- Choose the System. Type to filter the list by name; ↑ ↓ and ↩ pick one. The line below the list says how well that system is tested, for example “Tested with 18.6” for PostgreSQL or “Beta: Ferris IDEA has not tested this system against a server”.
- Give it a Name, then fill Host, Port, Database and User. An empty port means the system’s default (5432 for PostgreSQL, 3306 for MySQL and MariaDB, 1433 for SQL Server).
- Type the Password. The field says “kept in the system keychain”; once a password is stored it says “stored in the keychain; type to replace”. An empty field keeps the stored password.
- Click Test Connection. The result appears in a fixed area above the buttons (see Test a connection).
- Click Save, or press ↩. The connection appears in the tree as, for example, “PostgreSQL · db.example.com:5432/shop”, and its schema is read.
Tab and ⇧Tab move between fields, Esc closes the dialog without saving. To change a connection later, select it and press F4 or click ✎ (Data Source Properties…).
Paste a URL instead
Section titled “Paste a URL instead”The URL field takes a connection URL; ↩ fills the other fields from it. These forms are read:
postgresql://app@db.example.com:5432/shop?sslmode=verify-fullmysql://app@db.example.com:3306/shop?ssl-mode=verify-camariadb://app@db.example.com/shopsqlserver://app@db.example.com:1433/shoporacle://app@db.example.com:1521/FREEPDB1sqlite:data/shop.dbduckdb:data/analytics.duckdbThe schemes of the other built-in systems work as well (cockroachdb://, tidb://,
redshift:// and so on) and select that system. A URL that carries a password, in the user part or
as password=, is refused: the field is emptied and the message points you to the keychain. JDBC
URLs (jdbc:…) are not read here; see
Bring connections from IntelliJ IDEA for those.
Connect to a SQLite or DuckDB file
Section titled “Connect to a SQLite or DuckDB file”- Choose SQLite (or DuckDB) as the system. The host fields give way to File.
- Type the path. A relative path is read from the project folder, so
data/shop.dbkeeps working when the project moves. - If the file does not exist yet, click Create File. It is created with mode 600, never over an existing file and never in a folder that does not exist. Test Connection never creates a file.
Keep passwords out of the project
Section titled “Keep passwords out of the project”The project file .ferris-idea/connections.toml names the keychain entry, never the password:
[ferris-idea]kind = "connections"format = 1
[[connection]]id = "shop"name = "Shop"dialect = "postgresql"host = "db.example.com"port = 5432database = "shop"user = "app"ssl = "verify-full"secret = { service = "ferris-idea", account = "connection:shop" }
[[connection]]id = "local"name = "Local"dialect = "sqlite"path = "data/shop.db"- The keychain entry is service
ferris-idea, accountconnection:<id>. Removing a connection (Delete twice in the tree) removes its keychain entry too. - The file can be committed: it holds no secret. Keys at their default are left out, and an unknown key makes the whole file an error that names it, rather than being ignored.
- On Linux without a reachable Secret Service, or with a locked collection, saving is refused with the reason. Ferris IDEA never falls back to a file.
- When a password is missing, connecting stops before any network access and the message names the connection and the keychain entry.
Secure the connection with TLS
Section titled “Secure the connection with TLS”The SSH/SSL page sets the TLS mode with the SSL button, which steps through the modes:
| Mode | What it does |
|---|---|
verify-full |
TLS; checks the certificate chain and the host name. The default for a new connection. |
verify-ca |
TLS; checks the chain, not the host name. |
require |
TLS without certificate checks. |
prefer |
Like require. Falls back to an unencrypted connection only for a server on your own machine (localhost, 127.0.0.0/8, ::1, a socket folder), and only after TLS failed. On any other host it acts as require. |
disable |
No TLS. |
- CA file (PEM) replaces the system’s root certificates; it applies with
verify-caandverify-full. - Cert file and Key file set a client certificate: PEM with a PKCS#8 key for PostgreSQL,
or a password-less
.p12/.pfxbundle for PostgreSQL, MySQL and MariaDB. MySQL and MariaDB take bundles only. - A key file that others can read is refused (“restrict it with chmod 600”), and so is a key with a passphrase.
- TLS 1.2 is the minimum. A refused certificate never leads to a weaker mode by itself: the error
suggests naming the CA file, or
verify-cawhen the host name differs.
Reach the server through an SSH tunnel
Section titled “Reach the server through an SSH tunnel”For PostgreSQL, MySQL and MariaDB (and the systems built on them), the SSH/SSL page has SSH host, SSH port and SSH user.
- Type an alias from your
~/.ssh/configor a host name in SSH host, for examplebuild-host.example. Port and user come from your SSH configuration when left empty. - Click Test Connection. The result names the tunnel: “SSH tunnel: build-host.example (local end 127.0.0.1)”.
The tunnel runs your system’s ssh and authenticates with your keys and your SSH agent only. It
never asks for a password or a passphrase, refuses a host whose key is not already in your
known_hosts, and uses only post-quantum key exchange (OpenSSH 9.0 or later on both ends; ML-KEM
from 9.9). ProxyJump entries in your SSH configuration work. TLS still checks the database
server’s own host name through the tunnel.
Set the connection’s options
Section titled “Set the connection’s options”- Read-only on the General page keeps every console and agent of this connection to reading.
- Colour steps through red, orange, yellow, green, blue, violet, grey and none, and marks the connection in the Database tree, for example red for production.
- Comment is shown in the connection’s quick documentation.
- On the Options page: Auto-commit in consoles and editors (on by default; off starts
consoles in manual transactions), Startup script (SQL run after connecting), Connect
timeout (10 seconds when empty), Query timeout and Keep-alive in seconds, and
Schemas, a filter such as
app*, audit(all schemas when empty). - The query timeout is applied by PostgreSQL, MySQL and MariaDB; SQLite, SQL Server, Oracle and DuckDB ignore it.
Test a connection
Section titled “Test a connection”Test Connection uses the fields as they are, runs SELECT 1 (or the system’s own test query)
in the background and reports, for example:
Connected to ShopServer: PostgreSQL 18.6Driver: tokio-postgres (built in)Round trip: 2.4 msTLS: yesCopy puts these lines on the clipboard for a bug report; they never contain the password or the user name. When you change a field after a test, the result says “Outdated — the fields changed since the test”.
Bring connections from IntelliJ IDEA
Section titled “Bring connections from IntelliJ IDEA”When the project has the reference IDE’s .idea/dataSources.xml, the Database tool window lists
its data sources under “From the project’s .idea, not added yet”, each with Add…. Add fills the
dialog with the name, system and file or host, port and database; you enter the user and password.
SQLite, PostgreSQL, MySQL, MariaDB and SQL Server sources are read; TLS is set to verify-full
whatever the old URL said, and dataSources.local.xml is never read.
Share a connection without its secrets
Section titled “Share a connection without its secrets”Tools › Database › Export Connection… writes a .idcsources file without the keychain
reference, the agent permissions, the user name and absolute paths. Someone who imports it adds
their own password. Connector definitions of systems you added yourself travel as .idcconnector
files next to it; see Database systems.
When it does not work
Section titled “When it does not work”- “asks for a password and none was given”: no password is stored for this connection. Edit it (F4) and type the password.
- “the system keychain cannot be reached in this session”: on Linux, start or unlock your Secret Service (GNOME Keyring, KWallet); over SSH without a desktop session there is often none.
- A certificate error: name the server’s CA in CA file. If the server’s certificate is
issued for another host name,
verify-cachecks the chain without the name. - A local server without TLS fails with
verify-full; the message says thatdisableis your choice for that server. - “needs OpenSSH 9.0 or later; ML-KEM from 9.9”: the SSH server or your client is too old for post-quantum key exchange. Update OpenSSH; there is no fallback.
- Host key refused: connect once with
sshin a terminal and check the key, so that it is in yourknown_hosts. - SQLite “locked”: another program holds a write lock for longer than SQLite’s 5 second wait.
- “needs the ODBC route, which Ferris IDEA does not have yet”: systems such as Db2 or Snowflake are in the catalogue but cannot be connected yet.
To report a problem with one database system, use Tools › Database › Report a Problem with This Database…. It builds the report on your machine, replaces host, database and user names with placeholders unless you tick them in, and sends nothing until you copy it or open the issue in your browser.
The Database tool window has no default shortcut; assign one to Database (action
ActivateDatabaseToolWindow) in the keymap settings if you open it often. In its tree:
⌘N (CtrlN) new connection, F4 edit,
Delete remove. All shortcuts: Keyboard shortcuts.
For agents
Section titled “For agents”An agent can list connections and add one without a password (save_connection previews by
default and needs the right write); you type the password in the window. Testing or using a
connection needs that connection’s permissions, which only you grant:
Let an agent use a database.
add_idea_data_sourceAdd a data source from the reference IDE's.idea/dataSources.xml(as idea_project lists it) as a workspace connection, picked byname.database_problem_reportBuild the text of a problem report about a database system for the user to review: Ferris IDEA version, system, status, family, the failing step and error message, with passwords, user names and (unless include_hosts) host, port, database and IP addresses replaced by placeholders.export_connectionA workspace connection as a .idcsources file to share: no keychain reference, no agent permissions, no absolute file path, the user name only with include_user; lists what was left out.list_connectionsList the workspace's database connections (.ferris-idea/connections.toml) with URLs; passwords are never included.remove_connectionRemove a database connection of the workspace and its password in the system keychain, as Delete in the Database tool window does.save_connectionAdd or change a workspace database connection as the connection dialog does: server or SQLite/DuckDB file, user, SSL (new default verify-full), read-only, SSH tunnel (strict host keys, local end on 127.0.0.1), TLS files and options; omitted fields of a changed connection are kept.test_connectionTest a workspace database connection: connect with its stored password and run SELECT 1 read-only.
No tool matches. Try fewer words, or .