Connect using the CLI for Public Cloud Databases for Valkey
Connect to your Public Cloud Databases for Valkey using the Command Line Interface (CLI)
Objective
Public Cloud Databases allow you to focus on building and deploying cloud applications while OVHcloud takes care of the database infrastructure and maintenance in operational conditions.
This guide explains how to connect to a Valkey service instance with a Command Line Interface (CLI).
Requirements
- A Public Cloud project in your OVHcloud account
- A Valkey service running on your OVHcloud Public Cloud Databases (this guide can help you to meet this requirement)
- Configure your Valkey service to accept incoming connections
Concept
You can manage a Valkey service in several ways. One of the easiest, yet powerful, is to use a Command Line Interface (CLI), also known as a Console or Terminal. To interact correctly with the instance, we need to first install something called a client, in order to connect and control the Valkey service remotely. It's a Client-Server interaction.
Instructions
Installing valkey-cli on your client
valkey-cli is the official Valkey client. It is shipped with the Valkey packages.
You first need to install a software to interact with your instance remotely. This official software can be installed on various supports like your own computer, a VPS, a virtual machine... The only rule is to be able to reach the public network (Internet) and have sufficient privilege to install it.
Depending on your operating system:
- macOS (Homebrew):
brew install valkey - Debian / Ubuntu:
sudo apt install valkey-tools(Debian 13 or later, Debian 12 withbookworm-backports, Ubuntu 24.04 or later; not available on Ubuntu 22.04) - Fedora / RHEL:
sudo dnf install valkey - Alpine Linux:
apk add valkey-cli - Docker: the official
valkey/valkeyimage containsvalkey-cli, for exampledocker run -it --rm valkey/valkey valkey-cli --version. - Windows:
valkey-cliis not available natively. Use it from WSL (with one of the Linux commands above) or from Docker.
For other installation methods, refer to the official Valkey installation documentation.
Check that the client is installed:
The version number depends on your package. Your client must support TLS, which is the case for the packages listed above. valkeys:// URIs require valkey-cli 8.0 or later. With an older version (Ubuntu 24.04 installs 7.2), replace valkeys:// with rediss://.
redis-cli and other Redis-compatible clients can also connect to your Valkey service. redis-cli does not accept the valkeys:// scheme: use rediss:// instead, for example redis-cli --tls -u rediss://<username>:<password>@<host>:<port> PING.
We are now ready to learn how to connect to our instance.
Connection
Get the host, the port and the URI of your service in the Dashboard tab, Connection information section, as explained in the Configure incoming connections guide.
TLS is mandatory: connections without TLS are refused. Always use the valkeys:// scheme (or the --tls option). The server certificate is signed by a public certification authority, so you do not need to download a CA certificate or to add a --cacert option.
In your terminal, type:
Don't forget you need to modify the username, password, host and port.
The result should look like this:
It means that the instance is running and responding to your command.
To be in interactive mode, run the same command without any Valkey command at the end:
In our example, it will look like this:
Congratulations! You are now fully able to interact with your instance!
Use PING or HELLO to test a connection. INFO is refused to users whose permissions do not include it.
Avoiding the password on the command line
With the -u option, the password stays in your shell history and is visible in the list of processes, hence the warning displayed by valkey-cli. To avoid it, use one of these methods:
-
Connect without credentials, then authenticate inside the interactive session:
-
Let
valkey-cliprompt for the password, which is not displayed:
Do not put only the username in the URI (valkeys://<username>@<host>:<port>): valkey-cli reads the value before @ as a password, and authentication fails.
valkey-cli usage
You can manage your instance using the command line interface in interactive mode or by setting parameters as valkey-cli arguments.
Please follow the official valkey-cli documentation and the list of Valkey commands.
In the event of connection or command execution issues
If you do not authenticate, every command is refused with a NOAUTH error:
If the username or the password is wrong, authentication fails with a WRONGPASS error:
Check the username in the Users tab of your service. The password is displayed only once, at creation: if you lost it, reset it from the Users tab.
If the user is authenticated but its permissions (ACL) do not allow the key, the command or the channel, you get a NOPERM response:
In this case, review the keys, categories, commands and channels allowed for your user, in the Users tab or with the API. For more information, see the official Valkey ACL documentation.
Go further
Valkey capabilities and limitations
Configuring vRack for Public Cloud
Visit the Github examples repository to find how to connect to your database with several languages.
We want your feedback!
We would love to help answer questions and appreciate any feedback you may have.
For training or technical assistance implementing our solutions, contact your sales representative or visit our Professional Services page to request a quote and have your project analysed by our experts.
Are you on Discord? Connect to our channel at https://discord.gg/ovhcloud and interact directly with the team that builds our databases service!