Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the password to access redis-server in Linux?

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Redis is installed on the server today, so set the password to access redis-server for security.

First, find redis.conf files

Our server has installed redis, and now check the process of redis with the command:

[root@lnp ~] # ps-aux | grep redisroot 7374 0.0 145312 7524? Ssl 16:37 0:00 redis-server 192.168.17.105:6379root 10692 0.0 112724 984 pts/7 S + 16:54 0:00 grep-color=auto redis

You can see that the service address of our redis-server is 192.168.17.105 and the port is 6379. You need to specify the corresponding IP and port for external access:

Redis-cli-h 192.168.17.105-p 6379

Find the redis installation directory

> whereis redisredis: / usr/local/redis

We can see that redis is installed in this directory, and then find the configuration file redis.conf

> find / usr/local/redis/-name redis.conf/usr/local/redis/etc/redis.conf

Modify the configuration file:

Vim redis.conf

Just change the profile:

# requirepass foobaredrequirepass 123 specify password 123

As a final step, reload the configuration file:

Redis-server / usr/local/redis/etc/redis.conf

II. Connection testing

Access through password-a:

> redis-cli-h 192.168.17.105-p 6379-a 123

Running result:

[root@lnp etc] # redis-cliCould not connect to Redis at 127.0.0.1 Connection refusedCould not connect to Redis at: Connection refusednot connected > exit [root@lnp etc] # redis-cli-h 192.168.17.105-p 6379192.168.17.105 exit > keys * (error) NOAUTH Authentication required.192.168.17.105:6379 > exit [root@lnp etc] # redis-cli-h 192.168.17.105-p 6379-a 123Warning : Using a password with'- a 'option on the command line interface may not be safe.192.168.17.105:6379 > keys * (empty list or set) 192.168.17.105 exit

These are the details of how to set the redis access password under Linux. Please pay more attention to other related articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report