NOAUTH需要身份验证. Laravel + Redis [英] NOAUTH Authentication required. Laravel + Redis

查看:448
本文介绍了NOAUTH需要身份验证. Laravel + Redis的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误消息需要NOAUTH身份验证. 我的laravel版本是5.3,我正在使用predis 1.1.1连接redis.

I am getting error NOAUTH Authentication required. My laravel version is 5.3 and I am using predis 1.1.1 to connect redis.

在etc/redis/redis.conf中,我有:

in etc/redis/redis.conf I have:

bind 127.0.0.1
requirepass somepassword

我拥有的.env文件中

in .env file I have

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=somepassword
REDIS_PORT=6379

在config/database.php中,我有:

in config/database.php I have:

'redis' => [

        'cluster' => false,

        'default' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
        ],

我通过以下方式连接Redis:

I am connecting redis via:

self::$_db = \Redis::connection('default');

并像这样使用它:

self::$_db->pipeline(function ($pipe) use ($profile, $time,$type, $id) {
            $pipe->zadd(self::getProfileKey($profile, $type), $time, $id);
            $pipe->zadd(self::getProfileKey($profile), $time, $type . ':' . $id);
            $pipe->zadd(self::getModelKey($type,$id) . '::favoritedBy', $time, $profile->profile_id);
        });

因此,当我注释掉requirepass并将密码发送为null时,它可以工作,但是在密码到位时它不起作用并抛出错误NOAUTH Authentication required..我需要根据我的项目要求设置密码.请帮忙.预先感谢.

So, when I comment out requirepass and send password as null it works but it does not work and throw error NOAUTH Authentication required. when the password is in place. I need to have password in place as per my project requirement. Please help. Thanks in advance.

推荐答案

因此,经过一些研究,我为该问题找到了解决方案:

So after some research, I got a solution for this issue:

我们需要添加:

'options' => [
                'parameters' => ['password' => env('REDIS_PASSWORD', null)],
            ],

config数组中.请参阅下面的完整示例:database.php

In config array. See complete example below: database.php

'redis' => [

        'cluster' => false,

        'default' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 3,
        ],
        'options' => [
            'parameters' => ['password' => env('REDIS_PASSWORD', null)],
        ],
    ],

在.env文件中:

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=mmdgreat
REDIS_PORT=6379

这篇关于NOAUTH需要身份验证. Laravel + Redis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆