This section describes MySQL Shell's secret storage.
You can use the following functions to manage your secrets:
shell.storeSecret(key, value)
: Stores a secret with the given key.shell.readSecret(key)
: Reads a secret with the given key.shell.deleteSecret(key)
: Deletes a secret with the given key.shell.deleteAllSecrets()
: Deletes all secretsshell.listSecrets()
: Lists keys of all secrets
Secrets stored with this API are not accessible to the credential methods listed here: Section 4.4.2, “Working with Credentials”, nor can this API access credentials managed by that API.
To store a secret, use the shell.storeSecret(key,
value)
function. This function takes two parameters:
key
and value
. key is a
string that uniquely identifies the secret, while the value
parameter is an optional string that specifies the value of the
secret.
: String that uniquely identifies the secret.key
-
: (optional) String that specifies the value of the secret.value
If you do not provide a value, you will be prompted to enter it in a masked prompt. If a secret with the given key already exists in storage, its value will be overwritten.
For example:
shell.storeSecret("my_secret", "my_secret_value")
Alternatively, to enter your secret in a masked prompt, omit the
and enter
when prompted:
value
shell.storeSecret("my_secret")
Please provide the secret to store: *****************
To read a secret, use the
shell.readSecret(
function.
key
)
: String identifying the key of the secret to read.key
For example:
shell.readSecret("my_secret")
To list all secrets' keys stored by your current Secret Store
Helper, use the shell.listSecrets()
function.
This function returns a list of strings containing all keys in
storage.
In the following example, three secrets are defined in the current credential store and are returned as an array:
shell.listSecrets()
[
"my_secret2",
"my_secret1",
"my_secret"
]
To delete a secret, use the
shell.deleteSecret(
function.
key
)
: String identifying the key of the secret to delete.key
For example:
shell.deleteSecret("my_secret")