redis AUTH command
Translation results:
auth
abbr.author writer;authenticity certainty;authentic credibility;authoress female writer
redis AUTH commandsyntax
Function:By setting the value of the requirepass item in the configuration file (using the command CONFIG SET requirepass password), you can use a password to protect the Redis server.
Syntax: AUTH password
Instructions: If password protection is turned on, you must use the AUTH command after each connection to the Redis server Unlock. Only after unlocking can you use other Redis commands. If the password given in the AUTH command matches the password in the configuration file, the server will return OK and start accepting command input. On the other hand, if the passwords do not match, the server will return an error and ask the client to re-enter the password. Because of the high-performance characteristics of Redis, it is possible to try to guess many passwords in a short period of time, so please ensure that the password used is complex and long enough to avoid password guessing attacks.
Available versions: >= 1.0.0
Time complexity: O(1)
Return: Return OK when the password matches, otherwise return an error.
redis AUTH commandexample
# 设置密码 redis> CONFIG SET requirepass secret_password # 将密码设置为 secret_password OK redis> QUIT # 退出再连接,让新密码对客户端生效 [huangz@mypad]$ redis redis> PING # 未验证密码,操作被拒绝 (error) ERR operation not permitted redis> AUTH wrong_password_testing # 尝试输入错误的密码 (error) ERR invalid password redis> AUTH secret_password # 输入正确的密码 OK redis> PING # 密码验证成功,可以正常操作命令了 PONG # 清空密码 redis> CONFIG SET requirepass "" # 通过将密码设为空字符来清空密码 OK redis> QUIT $ redis # 重新进入客户端 redis> PING # 执行命令不再需要密码,清空密码操作成功 PONG