直接启动Redis服务:
#语法: “redis-server” “redis.conf”
#解释:直接启动Redis服务,应用redis.conf文件中的配置
“redis-server”:<redis-server文件的路径>/redis-server;(我的这个在/usr/local/bin里)
“redis.conf”:<redis.conf文件的路径>/redis.conf
[root@server1 bin]# redis-server /opt/modules/redis-3.0.6/redis.conf
这样启动不会出现这样的图
查看Redis服务是否开启:
ps -ef | grep redis
启动Redis客户端:
[root@server1 bin]# redis-cli
输入shutdown,即可停止Redis服务:
127.0.0.1:6379> shutdown
not connected>
输入shutdown后,若出现
(error) ERR Errors trying to SHUTDOWN. Check logs.
找到放置redis-cli、 redis-server文件的目录(我的在/usr/local/bin目录下)
[root@server1 bin]# ll //查看bin文件的权限
total 15472
drwxrwxrwx. 2 root root 4096 Oct 23 20:15 . //我的权限是777,r读w写x执行
[root@server1 bin]# cd .. //返回上层目录
[root@server1 local]# chmod 777 bin/ //将bin文件的权限改为777
redis操作命令
权限认证 auth <password>
选择数据库 select <number>
,一般redis是16个库,比如选择db3 命令为 select 3
查看当前库所有键(不推荐,性能损耗高) keys *
查看所有库的键 info keyspace
退出控制台 quit