w3resource

Redis Connection: AUTH password

Redis AUTH Command

Redis AUTH command is used to authenticate a password-protected server with a given password. If provided password matches the password in the configuration file, the server replies with the OK status code and starts accepting commands. Otherwise, an error is returned and the clients need to try a new password.

Here are some common uses and scenarios for the "AUTH password"command:

  • Client Authentication: Authenticates clients to the Redis server using a password, ensuring that only authorized clients can access the server.
  • Security: Enhances security by requiring a password before allowing access to the server's data and commands.
  • Access Control: Helps implement access control policies, restricting access to sensitive data and operations to authenticated clients only.
  • Prevent Unauthorized Access: Protects the Redis server from unauthorized access and potential misuse by requiring valid credentials.

Syntax:

Basic syntax of redis AUTH command is shown below:

AUTH PASSWORD

Available since

1.0.0.

Return Value

String reply

Return Value Type

String

Example:

redis 127.0.0.1:6379> AUTH PASSWORD
(error) ERR Client sent AUTH, but no password is set
redis 127.0.0.1:6379> CONFIG SET requirepass "mypass"
OK
redis 127.0.0.1:6379> AUTH mypass
Ok

Previous: SCRIPT LOAD
Next: ECHO



Follow us on Facebook and Twitter for latest update.