Redis learning-win10 install redis and create a service start

1. Download the Windows version of Redis
github download address: https://github.com/MSOpenTech/redis/tags
2. Install Redis
1. The version downloaded here is Redis-x64-3.2.100, my computer is win10 64-bit , So download the 64-bit version, unzip the downloaded file to the specified file.
Enter cmd while running, and point the directory to the unzipped Redis directory.
Insert picture description here
2. Start the command
redis-server redis.windows.conf, and the following figure shows that the startup is successful.
Insert picture description here
3. Redis change password
1. cmd to open a new command window, enter redis-cli -h 127.0.01 -p 6379 to connect
and then enter ping to check whether redis is started.
Insert picture description here
Output PONG, already started.
2. If there is a password to connect, you need to add a password.
Enter CONFIG get requirepass first to see if there is a password.
Insert picture description here
As you can see from the above, there is no password by default.
3. Modify the password.
Enter the CONFIG set requirepass "123456"
Insert picture description here
setting is successful, and then enter CONFIG get requirepass, it will prompt us that we do not have permission.
Insert picture description here
4. Enter AUTH 123456 to verify the password.
Insert picture description here
5. Close the current connection and re-use redis-cli -h host -p port -a password to connect and add the password.
Insert picture description here
Note: In normal use, you will find that your password is gone after the computer restarts or the server is powered off. How to solve it? Then look down.
6. The reason for the loss of the password: it is because our start command is started like this

redis-server.exe redis.windows.conf

In the redis.windows.conf configuration file, there is a line that requires password verification is commented; it
Insert picture description here
is the line #requirepass foobared, we remove the # sign in front of it, and then change foobared to the password we want to set.
7. Test service
7.1, enter SET mykey redis to add a piece of data
7.2, enter GET mykey to view the data
7.3, enter EXISTS mykey to check whether it exists, the key is the data of mykey.
Return 1 means it exists, 0 means it does not exist.
7.4. Enter del mykey to delete the record.
Return 1 means the deletion is successful, and 0 means the deletion fails.
Insert picture description here

Fourth, set up the Redis service
1. Because redis is started above, as long as the cmd window is closed, redis will disappear. So set redis as a service under windows.
2. Set the service command
redis-server --service-install redis.windows-service.conf --loglevel verbose After
Insert picture description here
entering the command, no error is reported, indicating that it is successful, refresh the service, and you will see that there is one more redis service.
Insert picture description here
Note: If the startup error 1067 is reported, create a new folder Logs in the redis directory and start again.
3. Commonly used redis service commands.
Uninstall service: redis-server --service-uninstall
start service: redis-server --service-start
stop service: redis-server --service-stop

4. Start the service.
Insert picture description hereHere is just a simple installation, deployment service use, more in-depth use can go to the redis Chinese website http://www.redis.net.cn/
There is a document in the downloaded decompression package with details instruction of
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_41812784/article/details/112778809
Recommended