zoukankan      html  css  js  c++  java
  • Redis 安装

    Windows 下安装

    下载地址:https://github.com/tporadowski/redis/releases

    Redis 支持 32 位和 64 位。这个需要根据你系统平台的实际情况选择,这里我们下载 Redis-x64-xxx.zip压缩包,解压后,将文件夹重新命名为 redis

    打开一个 cmd 窗口 使用 cd 命令切换目录到 解压redis目录 运行:

    redis-server.exe redis.windows.conf

    如果想方便的话,可以把 redis 的路径加到系统的环境变量里,这样就省得再输路径了,后面的那个 redis.windows.conf 可以省略,如果省略,会启用默认的。输入之后,会显示如下界面:

    这时候另启一个 cmd 窗口,原来的不要关闭,不然就无法访问服务端了。

    切换到 redis 目录下运行:

    redis-cli.exe -h 127.0.0.1 -p 6379

    设置键值对:

    set myKey abc

    取出键值对:

    get myKey

     

    • 最简单的启动方式是直接双击redis-server.exe
    • 如要设置密码,打开配置文件设置,记住修改的是哪一个,也可以两个都修改

    • 进入该目录下的命令行,执行redis-server.exe 你改的配置的文件名

    • redis-server.exe redis.windows.conf
    • 这样启动会有个问题,一旦你把命令行窗口关闭 redis也会被关闭,所以我们需要把它注册成服务
    • redis-server.exe --service-install redis.windows.conf 

       

    • 成功后就能在服务管理中找到

     或 运行命令行 输入 service 搜索直接打开  查看本地服务

     

    • 如果安装后默认已经添加了这个服务项,那就不能再次添加,你可以右键查看属性 ,可以看到使用的是哪个配置文件,然后按照需要修改就可以了。

    最后提醒一下,修改过配置,记得一定要重启redis!

    安装Redis Desktop Manager

    傻瓜式安装,点击下一步即可(注意更改安装目录)

    程序报错:

    Unable to connect to 127.0.0.1:6379

    redis.windows.conf

    ################################## NETWORK #####################################
    
    # By default, if no "bind" configuration directive is specified, Redis listens
    # for connections from all the network interfaces available on the server.
    # It is possible to listen to just one or multiple selected interfaces using
    # the "bind" configuration directive, followed by one or more IP addresses.
    #
    # Examples:
    #
    # bind 192.168.1.100 10.0.0.1
    # bind 127.0.0.1 ::1
    #
    # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
    # internet, binding to all the interfaces is dangerous and will expose the
    # instance to everybody on the internet. So by default we uncomment the
    # following bind directive, that will force Redis to listen only into
    # the IPv4 lookback interface address (this means Redis will be able to
    # accept connections only from clients running into the same computer it
    # is running).
    #
    # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
    # JUST COMMENT THE FOLLOWING LINE.
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    bind 127.0.0.1
    127.0.0.1只允许本地连

    改成

    ################################## NETWORK #####################################
    
    # By default, if no "bind" configuration directive is specified, Redis listens
    # for connections from all the network interfaces available on the server.
    # It is possible to listen to just one or multiple selected interfaces using
    # the "bind" configuration directive, followed by one or more IP addresses.
    #
    # Examples:
    #
    # bind 192.168.1.100 10.0.0.1
    # bind 127.0.0.1 ::1
    #
    # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
    # internet, binding to all the interfaces is dangerous and will expose the
    # instance to everybody on the internet. So by default we uncomment the
    # following bind directive, that will force Redis to listen only into
    # the IPv4 lookback interface address (this means Redis will be able to
    # accept connections only from clients running into the same computer it
    # is running).
    #
    # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
    # JUST COMMENT THE FOLLOWING LINE.
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    bind 0.0.0.0
    0.0.0.0允许任何IP连
  • 相关阅读:
    Directx
    apr库开发
    linux 上編譯apache
    数字信号处理---FFT
    C# Parallel用法
    C#线程同步--线程通信
    C#线程同步--限量使用
    C#线程安全类型
    C# Task用法
    C# ThreadPool类(线程池)
  • 原文地址:https://www.cnblogs.com/mingforyou/p/14666226.html
Copyright © 2011-2022 走看看