简体   繁体   English

如何在Node.js中使用Redis进行身份验证?

[英]How to do authentication with redis in node.js?

I'm using the node_redis module and I'm not being able to determine a password for redis succesfully. 我正在使用node_redis模块,但无法成功确定redis的密码。

Here's my code: 这是我的代码:

var redis = require("redis"),
    client = redis.createClient(6379, "localhost"); 

client.auth("password", function (err) { if (err) throw err; }); 

Whenever I run this file in the command line I get the following message: "Redis does not require a password, but a password was supplied." 每当我在命令行中运行此文件时,都会收到以下消息:“ Redis不需要密码,但是提供了密码。”

I keep getting the same error, even though I tried to change the redis.conf file that is in my computer's redis instalation: 即使尝试更改计算机redis安装中的redis.conf文件,我仍然遇到相同的错误:

requirepass password

Please, shed some light on the issue. 请阐明一下这个问题。

When you start the redis server use this command: redis-server /path/to/redis.conf 启动Redis服务器时,请使用以下命令:redis-server /path/to/redis.conf

this way it will authenticate connections using password specified in redis.conf 这样,它将使用redis.conf中指定的密码对连接进行身份验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM