配置文件安装的时候有设置,我的在/etc/redis.conf

端口号:

# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port 6565

密码:

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
requirepass THISISMYPASS

终端下连接方法:

[root@machineName ~]# redis-cli -p 6565 -a THISISMYPASS
                     #redis-cli -p 端口  -a 密码