How to Configure Gemini CLI SQL Server Credentials
To set up gemini cli sql server credentials, make a scoped database user first. Then pass those login details to the agent tool or shell session. Teams often start by reusing a broad admin login in a local file. That shortcut gives the terminal agent full power over every table. If a prompt goes wrong, an overly broad role can change or delete records. A safer path uses a dedicated user with strict read permissions. How to set up gemini cli sql server credentials SQL Server separates server l
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
To set up gemini cli sql server credentials, make a scoped database user first. Then pass those login details to the agent tool or shell session. Teams often start by reusing a broad admin login in a local file. That shortcut gives the terminal agent full power over every table. If a prompt goes wrong, an overly broad role can change or delete records. A safer path uses a dedicated user with strict read permissions.
How to set up gemini cli sql server credentials
SQL Server separates server logins from individual database users. A database user is the identity a login uses inside one specific database. When someone needs many databases on one instance, admins make a master login. Then they map that login to a user inside each target database. When the tool only needs one database, a contained user is an option. A contained user holds its own password inside that single database. It does not tie back to a login in the master database. An admin must turn on contained databases on the server and database first.
After creating the user, you assign a fixed database role. The built-in reader role lets the user read all user tables and views. A deny writer role blocks the user from adding, changing, or deleting rows. You cannot alter the permissions built into these fixed database roles. By default, every role on the database includes the basic right to connect. Avoid the owner role for any automated terminal agent. The owner role can change settings and even drop the whole database.
How the terminal agent uses database logins
Gemini CLI runs in your terminal and executes shell commands or external tools. To query a database, the agent uses credentials stored on the developer machine. Developers usually put the username and password in local shell variables or config files. When the agent runs a query tool, that process reads the local secret. It opens a direct session to SQL Server using that static database user.
This setup is fast to build, but the secret lives on the laptop. Anyone with access to the shell can read the plain password. Every developer also ends up holding a copy of the database login. Rotating that password means updating files across every machine on the team. If an agent reads the config file, the secret can enter the prompt context.
Ephemeral Credentials + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native roles solve and what they leave open
Native SQL Server roles decide who can log in to the database. They also control which broad actions a user can run across tables. Putting an agent in a reader role stops accidental table drops and row deletes. That is an important first step for any team using AI coding tools.
Still, fixed roles do not inspect individual queries while they run. A reader role gives access to every user table and view at once. If a table holds emails, phone numbers, or card numbers, the query returns them. Native roles cannot rewrite matched fields in results before the agent gets them. They also do not tie a shared SQL login back to a human identity. In the database logs, every query just shows the shared service username. You cannot require a human to approve one risky query in real time.
Govern SQL Server queries and responses in flight
Table grants decide which SQL Server objects a caller may touch. They do not check query intent or rewrite sensitive values in results across every client and agent. By design, hoop.dev sits inline in the TDS wire protocol next to SQL Server as a sidecar for your SQL Server. On every production batch from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for approval.
With hoop.dev guardrails and hoop.dev data masking, banned statements are refused or held for review, matched sensitive fields in supported result columns are masked in memory, and each decision is logged. Check out the code on GitHub.
Frequently asked questions
Should I use a master login or a contained user for Gemini CLI?
Use a contained database user if the agent only needs one database. It keeps the user and password inside that single database without a master login. Use a login in master only when the user must span many databases.
Does the built-in reader role hide sensitive columns from the agent?
No, the fixed reader role lets the user read all user tables and views. It cannot mask emails, phone numbers, or national IDs inside query results. You need extra controls if you want to rewrite sensitive fields in flight.
Why is the database owner role risky for a CLI coding agent?
The fixed owner role can run all maintenance and setup tasks in SQL Server. A user in that role can even drop the entire database if a command misfires. Always restrict coding agents to read-only roles or custom permissions on safe tables.
Related guides
In this post