Linux指定端口连接Redis
warning:
这篇文章距离上次修改已过437天,其中的内容可能已经有所变动。
在Linux系统中,要指定端口连接Redis,你可以使用redis-cli命令行工具并指定-p参数 followed by the port number. Here is an example command:
redis-cli -h <your_redis_host> -p <your_redis_port>替换<your_redis_host>为你的Redis服务器的主机名或IP地址,替换<your_redis_port>为你的Redis服务器监听的端口号。
例如,如果你的Redis服务器运行在本地机器上,并且监听在默认端口6379,你可以使用:
redis-cli -h 127.0.0.1 -p 6379或者如果你想要连接到远程Redis服务器,例如IP地址为192.168.1.100,并且它监听在端口6380,你可以使用:
redis-cli -h 192.168.1.100 -p 6380如果Redis服务器设置了密码,你还需要使用-a参数 followed by the password:
redis-cli -h 192.168.1.100 -p 6380 -a your_redis_password替换your_redis_password为你的Redis服务器的实际密码。
评论已关闭