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

Set redis access password

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

On the server, take the linux server as an example to configure the password for redis.

1. The first way (the current method of configuring redis passwords in linux is temporary, and the password will expire after redis restart,)

(1) enter redis first. If redis is not enabled, you need to enable it first:

# redis-cli-p 6379

127.0.0.1purl 6379 >

(2) check whether the current redis has set a password:

127.0.0.1 purl 6379 > config get requirepass

1) "requirepass"

2) "

(3) if there is no password as shown above, set the password now:

127.0.0.1 purl 6379 > config set requirepass abcdefg

OK

127.0.0.1purl 6379 >

(4) if you check the current redis again, you will be prompted to need a password:

127.0.0.1 purl 6379 > config get requirepass

(error) NOAUTH Authentication required.

127.0.0.1purl 6379 >

two。 The second way (permanent way)

If you need a permanent configuration password, go to the configuration file of redis.conf to find the parameter requirepass, as follows:

Modify redis.conf configuration file

# requirepass foobared

Requirepass 123 specify password 123

Just restart redis after saving it

Connect redis

1.redis-cli connection redis

# redis-cli

127.0.0.1 6379 > keys *

(error) NOAUTH Authentication required.

127.0.0.1 auth 6379 > specify password

OK

127.0.0.1 6379 > keys *

1) "a"

2) "cit"

3) "clist"

4) "1"

127.0.0.1purl 6379 >

2.Jedis connection redis

Java code mode

/ / Connect to the redis server, 192.168.0.100pur6379

Jedis = new Jedis ("ip", 6379)

/ / permission authentication

Jedis.auth ("password")

Configuration file mode

Other commands of redis.

If you need to close redis:

# pkill redis

If you need to enable redis:

# redis-server &

The purpose of the plus-symbol is to convert this process into a background process without consuming shell services.

The more you invest, the more value you get.

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

Servers

Wechat

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

12
Report