Redis AUTH command in Python
This worked great for me.
redis_db = redis.StrictRedis(host="localhost", port=6379, db=0, password='yourPassword')
If you have Redis running on a different server, you have to remember to add bind 0.0.0.0 after bind 127.0.0.1 in the config (/etc/redis/redis.conf). On Ubuntu this should only output one line with 0.0.0.0:
sudo netstat -lnp | grep redis
My result for netstat:
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 6089/redis-server 0
Thanks to the hints from the comments. I found the answer from https://redis-py.readthedocs.org/en/latest/.
It says
class redis.StrictRedis(host='localhost', port=6379, db=0, password=None, socket_timeout=None, connection_pool=None, charset='utf-8', errors='strict', unix_socket_path=None)
So AUTH
is in fact password
passed by keyword argument.
You need to use password instead of AUTH:
Python 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import redis >>> r = redis.StrictRedis(host='localhost',port=6379,db=0,password='Prabhat') >>> print(r) Redis<ConnectionPool<Connection<host=localhost,port=6379,db=0>>> >>>```