# How do I type psql or mysql on a server without pasting the password?

Bind a saved password to psql or mysql on a host. Valakes answers the prompt from its vault, so by default the password never goes through the command line.

Source: https://valakes.com/guides/auto-fill-a-database-password-over-ssh/

Last updated: 2026-11-29

Save the password in the Valakes vault and bind it to psql on that host. When you run the command, Valakes answers the password prompt itself.

Typing a database password at every prompt is slow, and writing it into the command puts it in the process list of the server, and the server may keep it in its history. Valakes keeps the password in its vault and answers the prompt for you. This guide uses `psql`. The other built-in tools work the same way. If you look after only a few servers, [keeping them in one place without a pile of terminals](https://valakes.com/use-cases/a-few-servers/) shows where this fits.

## Steps

1. **Type the command as usual**

   Write the command in the composer, for example `psql -U app -h postgres appdb`, and look above the composer before you press Enter. Valakes recognizes the tool and shows a card, "Credentials for this host".

   If no credential is bound to `psql` on this host, the card says so and offers **Add a binding...**. It also says that the password is sent as a prompt answer and never placed in the command line. The same works for `mysql`, `mongosh`, `redis-cli`, `curl`, `docker login`, `sudo`, `git`, `ssh` and `scp`.

2. **Bind a saved password to the tool**

   **Add a binding...** opens Settings, Credentials and vault, with a dialog titled "Bind a credential to psql (PostgreSQL client) on" your host. It lists the credentials in the vault, here one password named `pg-prod`. Choose the one Valakes may use for this tool on this host, or press **Add a credential** to save a new password first.

   The dialog names the server in your command and says the binding will cover it. After you choose the credential, the next screen of the dialog lets you change that. A binding belongs to one tool on one host.

3. **Decide whether Valakes fills it in on its own**

   On that screen a binding has an **Auto-fill** switch. With it on, Valakes answers the password prompt itself. With it off, a chip under the composer asks "Fill with pg?" and waits for you each time.

   Leave Auto-fill off for a password you want to confirm every time. Agents can use only credentials whose binding has Auto-fill on. [Keep your SSH password away from Claude Code](https://valakes.com/guides/let-claude-code-run-commands-without-a-password/) shows how an agent uses one.

4. **Run the command**

   Type the command again. The pictures come from different test runs, so the names differ. A chip in the composer, "password: pg-test" in the picture, names the credential that will be used, and the card above it lists the binding with "Auto-fill on". Press Enter.

   When `psql` asks for the password, Valakes checks that the prompt is genuine and sends the value once, from its main process straight to the server connection. The value does not pass through the window, the composer, the command history or any log. Your history keeps `{{cred:name}}`, never the value.

5. **Use the placeholder when a tool has no prompt**

   Some commands take the password on the command line. For `docker login --password-stdin`, a small helper in your shell reads the value with echo off and hands it to the program.

   As a last resort you can write the placeholder into the command yourself, for example `curl -u user:{{cred:http}}`. That needs the binding's **Allow inline** or a confirmation each time. A native dialog warns that the password will appear in the process list on the server and may be kept in its history. It also stays in this terminal's scrollback.

## What it does not do

A placeholder works only in a simple command, not in a pipe or a list, and only for the tool and the host it is bound to.

There is one gap that Valakes cannot close. The program that reads the prompt belongs to the server. If it exits in the instant between its prompt and the answer, the answer can land at the shell prompt as typed text and enter the server's shell history. Valakes narrows that window and masks the echo on your screen.

Valakes can only protect values it holds in the vault. A password that sits in a file on the server, or that a program prints, is not protected. If an agent reads that output, Valakes replaces only the saved values it knows. Inline use is only for you, never for an agent. Do not put a password in a broadcast command: each host fills its own prompt, and a password you type yourself goes to every host as typed.

## Documentation and help

[Read the docs: Credentials and auto-fill](https://docs.valakes.com/credentials/)

[Help centre: The password was not filled in](https://support.valakes.com/the-password-was-not-filled-in/)

## Read next

- [Database passwords fill themselves](https://valakes.com/features/password-auto-fill/): Save a password once, bind it to a tool on a host, and Valakes answers that tool's password prompt for you. Your screen and your history keep a placeholder, never the value.
- [How do I run psql without typing the password?](https://valakes.com/learn/psql-without-password-prompt/): Put one line in ~/.pgpass in the form hostname:port:database:username:password and run chmod 600 on the file. psql then finds the password itself, and psql -w makes a script fail with an error instead of waiting for a prompt that nobody can answer.
- [How do I get rid of "Using a password on the command line interface can be insecure"?](https://valakes.com/learn/mysql-password-command-line-warning/): The warning appears because you gave the password as a value, as in -ps3cret, and then it sits in the command line where ps can show it. Move it into a [client] section of ~/.my.cnf with mode 600, or into a login path made by mysql_config_editor, and run mysql without it.
- [How do I let a user run one command with sudo?](https://valakes.com/learn/sudo-for-one-command/): Write a rule that names the command with its full path and exact arguments, put it in its own file under /etc/sudoers.d/, check it with visudo -cf, and install it with mode 440. Do not use wildcards in the arguments, and do not allow editors or any program that can start a shell.
- [How do I generate an SSH key and put it on a server?](https://valakes.com/learn/ssh-keys/): Run ssh-keygen -t ed25519, then ssh-copy-id -i ~/.ssh/id_ed25519.pub user@host. The private key stays on your computer, the public key goes into ~/.ssh/authorized_keys on the server, and you log in without a password.

The screenshots show Valakes built from commit 0b8738d, taken on 25 November 2026.
