Redis installation and configuration
- download
- Unpack the
- Windows service
- Configure the Redis environment
- Set a Redis password (temporary and permanent)
- Configure redis to be connected remotely
A, download
Download the Redis zip on GitHub (even numbers are stable versions):github.com/MicrosoftAr…
Baidu web disk: extraction extraction code: RD64; Visualization tool
Second, the decompression
Decompress redis. Zip to generate the following file directory:
The startup test is started on the terminal using the configuration file redis.windows.conf.
redis-server redis.windows.conf
Third, make Redis a Windows service
Install Redis as a Windows service:
Delete all information in the address bar of the unzip directory, then enter CMD and press Enter (Windows 7 requires administrator privileges). This opens a DOS window in the current file
Enter the command: redis-server –service-install redis.windows.conf Default port 6379. If you need to change the default port, check the redis.windows.conf.
Command 1: redis-server –service-install redis.windows.conf
Command 2: redis-server –service-install redis.windows-service.conf
Note: Both of the preceding commands can be executed successfully. The only difference is that the configuration file of command 1 is redis.windows.conf
The configuration file to be modified later in command 2 is redis.windows-service.conf
After the execution is successful:
Then use Win + R to open the run window and type services.msc
After confirming, a service window will open. Press R(uppercase) to select the service starting with R/ R:
Now that Windows service is ready, right-click Redis and select Start.
Four, set up the Redis environment
Set redis to environment variables:
5. Set the redis password
After redis is installed, there is no password by default, but in the development environment we need to set a password to connect.
Set redis password:
At this point, use CMD to open the DOS window and type: redis-cli, followed by auth
You are prompted to enter a password. ERR Client sent AUTH, but no password is set
Set temporary password:
CONFIG SET requirepass “123456” ; Set the password of the user to 123456. Then use Auth 123456 redis to prompt OK to indicate that the password is set successfully.
However, the disadvantage of this method is that when the Redis service is stopped, the above steps need to be performed again before starting the Redis service.
Set a permanent password:
Conf file in the redis decompression directory. Open the file and find requirepass foobared
Copy this line with the comment symbol (” # “) removed so that the first word of the current line is preceded by no space. Change foobared to 123456 (custom password). This eliminates the need to set a password every time you start the Redis service.
, and restart the Redis service. You can find that the login is successful
6. Remote connection
Remote connection redis:
Exe -h IP address -p port number -a password -h < IP address >, default is 127.0.0.1 -p < port >, default is 6379 -a < password >, To pass the password, you need to go to redis.windows.conf and search bind. The default is bind 127.0.0.1, which means only 127.0.0.1 can be connected.
Comment bind out here (# bind 127.0.0.1) and do not use it. All IP addresses are allowed access
Seven, common commands:Segmentfault.com/a/119000001…
- Login # redis
- redis-cli
- Enter the login password
- auth password
- # check all keys
- keys *
- Clear all database caches
- flushall
- Clear the current db cache
- flushdb
- # Check redis usage
- info
- info memory
- Dbsize Indicates the total number of keys