redis重启命令Linux,Redis启动、配置 及 常用命令-Go语言中文社区

启动 Redis 服务

src/redis-server或者src/redis-server redis.conf

注:src/redis-server 会不加载redis.conf配置文件,提示: Warning: no config file specified, using the default config.

3b3ed9f185a9806c9ca876acf7056e7a.png标题

而:src/redis-server redis.conf 为载入redis.conf配置的启动方式

a832538ac40eca1b390c5b14bc99d681.png标题

src/redis-server redis.conf 1>log.log 2>errlog.log

1为标准输出,2为错误输出

将 Redis 作为 Linux 服务随机启动

vi /etc/rc.local, 加入代码:   /root/install/redis-2.4.9/src/redis-server

或参考:

Redis客户端连接

src/redis-cli

停止redis服务:

src/redis-cli shutdown

修改密码:

vim /root/install/redis-2.4.9/redis.conf文件

修改requirepass 后面foobared为自己的密码,如 123456

9b7a230db34291e283c6c8c506040bfa.png

允许客户端redis-cli 用ip、port访问:

(1).不能访问之前:

f28c70461cdf39cd0e08731737394c0c.png

(2).修改redis.conf文件,注释掉 bind 127.0.0.1,kill 掉服务,或者客户端 src/redis-cli shutdown 命令关闭后重启服务。

---------------------------------------------------------------------------------------------

增删改查命令:

9804e7b34afd482d3986ff40ff158b17.png

keys *

取出当前匹配的所有key

> exists larry

(integer) 0

当前的key是否存在

del lv

删除当前key

expire

设置过期时间

> expire larry 10

(integer) 1

> move larry ad4

(integer) 1

移动larry键值对到ad4数据库

> persist lv

(integer) 1

移除当前key的过期时间

randomkey

随机返回一个key

rename

重命名key

type

返回值的数据类型

type testlist

list

> ping

PONG

测试连接是否还在

>echo name

"larry"

打印

> select ad4databank

OK

数据库切换

> quit

退出连接

> dbsize

(integer) 12

当前数据库中key的数量

> info

服务器基本信息

monitor

实时转储收到的请求

config get

获取服务器的参数配置

flushdb

清空当前数据库

flushall

清除所有数据库

其他:

参考网址:http://redisdoc.com/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值