您的位置:首页 > 数据库 > Redis

Redis中存储value中文显示问题解决

2017-08-22 22:52 423 查看

Redis的value存储中文后,get之后显示16进制的字符串”\xe4\xb8\xad\xe5\x9b\xbd”,如何解决?

127.0.0.1:6379> set China 中国
OK
127.0.0.1:6379> get China
"\xe4\xb8\xad\xe5\x9b\xbd"
127.0.0.1:6379> exit


解决方法:

启动redis-cli时,在其后面加上–raw即可,汉字即可显示正常。

[root@localhost redis]# ./bin/redis-cli --raw
127.0.0.1:6379> get China
中国
127.0.0.1:6379>


使用 redis-cli –help 获取更多帮助信息

[root@localhost redis]# ./bin/redis-cli --help
redis-cli 4.0.1

Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]
-h <hostname>      Server hostname (default: 127.0.0.1).
-p <port>          Server port (default: 6379).
-s <socket>        Server socket (overrides hostname and port).
-a <password>      Password to use when connecting to the server.
-r <repeat>        Execute specified command N times.
-i <interval>      When -r is used, waits <interval> seconds per command.
It is possible to specify sub-second times like -i 0.1.
-n <db>            Database number.
-x                 Read last argument from STDIN.
-d <delimiter>     Multi-bulk delimiter in for raw formatting (default: \n).
-c                 Enable cluster mode (follow -ASK and -MOVED redirections).
--raw              Use raw formatting for replies (default when STDOUT is
not a tty).
--no-raw           Force formatted output even when STDOUT is not a tty.


–raw 使用RAW格式回帖(默认时是不是一个TTY标准)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: