How to set password for Redis?

后端 未结 10 1281
长发绾君心
长发绾君心 2021-01-29 19:17

I\'m working with redis on my local machine so I dont really need to set up a password to connect to the server with my php client (I\'m using predis as a client). However, I\'

相关标签:
10条回答
  • 2021-01-29 19:56

    step 1. stop redis server using below command /etc/init.d/redis-server stop step 2.enter command : sudo nano /etc/redis/redis.conf

    step 3.find # requirepass foobared word and remove # and change foobared to YOUR PASSWORD

    ex. requirepass root

    0 讨论(0)
  • 2021-01-29 19:57

    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
    
    0 讨论(0)
  • 2021-01-29 20:01

    using redis-cli:

    root@server:~# redis-cli 
    127.0.0.1:6379> CONFIG SET requirepass secret_password
    OK
    

    this will set password temporarily (until redis or server restart)

    test password:

    root@server:~# redis-cli 
    127.0.0.1:6379> AUTH secret_password
    OK
    
    0 讨论(0)
  • 2021-01-29 20:02
    sudo nano /etc/redis/redis.conf 
    

    find and uncomment line # requirepass foobared, then restart server

    now you password is foobared

    0 讨论(0)
  • 2021-01-29 20:02

    How to set redis password ?

    step 1. stop redis server using below command /etc/init.d/redis-server stop

    step 2.enter command : sudo nano /etc/redis/redis.conf

    step 3.find # requirepass foobared word and remove # and change foobared to YOUR PASSWORD

    ex. requirepass root

    0 讨论(0)
  • 2021-01-29 20:03

    i couldnt find though what i should add exactly to the configuration file to set up the password.

    Configuration file should be located at /etc/redis/redis.conf and password can be set up in SECURITY section which should be located between REPLICATION and LIMITS section. Password setup is done using the requirepass directive. For more information try to look at AUTH command description.

    0 讨论(0)
提交回复
热议问题