Home Database Mysql Tutorial redis配置认证密码

redis配置认证密码

Jun 07, 2016 pm 04:13 PM
redis password Certification pass Configuration

redis配置密码 1.通过配置文件进行配置 yum方式安装的redis配置文件通常在/etc/redis.conf中,打开配置文件找到 #requirepass foobared 去掉行前的注释,并修改密码为所需的密码,保存文件 requirepass myRedis 重启redis sudo service redis restart#或者sudo

redis配置密码

1.通过配置文件进行配置
yum方式安装的redis配置文件通常在/etc/redis.conf中,打开配置文件找到
#requirepass foobared
Copy after login
去掉行前的注释,并修改密码为所需的密码,保存文件
requirepass myRedis
Copy after login
重启redis
sudo service redis restart
#或者
sudo service redis stop
sudo redis-server /etc/redis.conf
Copy after login
这个时候尝试登录redis,发现可以登上,但是执行具体命令是提示操作不允许
redis-cli -h 127.0.0.1 -p 6379
redis 127.0.0.1:6379>
redis 127.0.0.1:6379> keys *
(error) ERR operation not permitted
redis 127.0.0.1:6379> select 1
(error) ERR operation not permitted
redis 127.0.0.1:6379[1]> 
Copy after login
尝试用密码登录并执行具体的命令看到可以成功执行
redis-cli -h 127.0.0.1 -p 6379 -a myRedis
redis 127.0.0.1:6379> keys *
1) "myset"
2) "mysortset"
redis 127.0.0.1:6379> select 1
OK
redis 127.0.0.1:6379[1]> config get requirepass
1) "requirepass"
2) "myRedis"
Copy after login


2.通过命令行进行配置

redis 127.0.【本文来自鸿网互联 (http://www.68idc.cn)】0.1:6379[1]> config set requirepass my_redis
OK
redis 127.0.0.1:6379[1]> config get requirepass
1) "requirepass"
2) "my_redis"
Copy after login
无需重启redis
使用第一步中配置文件中配置的老密码登录redis,会发现原来的密码已不可用,操作被拒绝

redis-cli -h 127.0.0.1 -p 6379 -a myRedis
redis 127.0.0.1:6379> config get requirepass
(error) ERR operation not permitted
Copy after login
使用修改后的密码登录redis,可以执行相应操作
redis-cli -h 127.0.0.1 -p 6379 -a my_redis
redis 127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "my_redis
Copy after login
尝试重启一下redis,用新配置的密码登录redis执行操作,发现新的密码失效,redis重新使用了配置文件中的密码
sudo service redis restart
Stopping redis-server:                                     [  OK  ]
Starting redis-server:                                     [  OK  ]
redis-cli -h 127.0.0.1 -p 6379 -a my_redis
redis 127.0.0.1:6379> config get requirepass
(error) ERR operation not permitted
redis-cli -h 127.0.0.1 -p 6379 -a myRedis
redis 127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "myRedis"
Copy after login

除了在登录时通过 -a 参数制定密码外,还可以登录时不指定密码,而在执行操作前进行认证。
redis-cli -h 127.0.0.1 -p 6379
redis 127.0.0.1:6379> config get requirepass
(error) ERR operation not permitted
redis 127.0.0.1:6379> auth myRedis
OK
redis 127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "myRedis"
Copy after login


3.master配置了密码,slave如何配置

若master配置了密码则slave也要配置相应的密码参数否则无法进行正常复制的。
slave中配置文件内找到如下行,移除注释,修改密码即可
#masterauth  mstpassword
Copy after login


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution to 0x80242008 error when installing Windows 11 10.0.22000.100 Solution to 0x80242008 error when installing Windows 11 10.0.22000.100 May 08, 2024 pm 03:50 PM

1. Start the [Start] menu, enter [cmd], right-click [Command Prompt], and select Run as [Administrator]. 2. Enter the following commands in sequence (copy and paste carefully): SCconfigwuauservstart=auto, press Enter SCconfigbitsstart=auto, press Enter SCconfigcryptsvcstart=auto, press Enter SCconfigtrustedinstallerstart=auto, press Enter SCconfigwuauservtype=share, press Enter netstopwuauserv , press enter netstopcryptS

What should I do if my Win10 password does not meet the password policy requirements? What to do if my computer password does not meet the policy requirements? What should I do if my Win10 password does not meet the password policy requirements? What to do if my computer password does not meet the policy requirements? Jun 25, 2024 pm 04:59 PM

In the Windows 10 system, the password policy is a set of security rules to ensure that the passwords set by users meet certain strength and complexity requirements. If the system prompts that your password does not meet the password policy requirements, it usually means that your password does not meet the requirements set by Microsoft. standards for complexity, length, or character types, so how can this be avoided? Users can directly find the password policy under the local computer policy to perform operations. Let’s take a look below. Solutions that do not comply with password policy specifications: Change the password length: According to the password policy requirements, we can try to increase the length of the password, such as changing the original 6-digit password to 8-digit or longer. Add special characters: Password policies often require special characters such as @, #, $, etc. I

How to easily get the WiFi password of a connected mobile phone (quickly find the WiFi password saved in the mobile phone) How to easily get the WiFi password of a connected mobile phone (quickly find the WiFi password saved in the mobile phone) May 08, 2024 pm 01:10 PM

Our mobile phones have become an integral part of our lives in modern society. Wireless network connections have also become an indispensable tool in our daily lives. However, sometimes we face such a situation: we want to connect to other devices but are unable to do so, we connect to WiFi but forget the password. How to easily get the WiFi password of a connected mobile phone? Find the saved WiFi password on the phone 1. Find the "WiFi" option in the settings, find and click it, and enter the phone's settings interface "WiFi" to enter the WiFi settings page, option. 2. Open the connected WiFi network details, find the name of the connected WiFi network, click to enter the detailed information page of the network, in the WiFi settings page. 3.

Golang API caching strategy and optimization Golang API caching strategy and optimization May 07, 2024 pm 02:12 PM

The caching strategy in GolangAPI can improve performance and reduce server load. Commonly used strategies are: LRU, LFU, FIFO and TTL. Optimization techniques include selecting appropriate cache storage, hierarchical caching, invalidation management, and monitoring and tuning. In the practical case, the LRU cache is used to optimize the API for obtaining user information from the database. The data can be quickly retrieved from the cache. Otherwise, the cache can be updated after obtaining it from the database.

Caching mechanism and application practice in PHP development Caching mechanism and application practice in PHP development May 09, 2024 pm 01:30 PM

In PHP development, the caching mechanism improves performance by temporarily storing frequently accessed data in memory or disk, thereby reducing the number of database accesses. Cache types mainly include memory, file and database cache. Caching can be implemented in PHP using built-in functions or third-party libraries, such as cache_get() and Memcache. Common practical applications include caching database query results to optimize query performance and caching page output to speed up rendering. The caching mechanism effectively improves website response speed, enhances user experience and reduces server load.

How to reset WiFi password through router (simple steps to help you protect your home network security) How to reset WiFi password through router (simple steps to help you protect your home network security) May 03, 2024 pm 03:01 PM

Wireless networks have become an integral part of our lives in modern society. Securing your home WiFi network is also becoming increasingly important, however. Resetting your WiFi password is a critical task to ensure network security. To protect your home network security, this article will introduce you how to reset your WiFi password through your router. Understand the router login interface. Connect to the router and open the management page. Enter the administrator username and password. Enter the wireless settings option. Find the current WiFi name and password. Back up the network settings. Select the modify password option. Enter the new WiFi password. Set a strong password. Save the settings and exit. Reconnect the device to Test the new WiFi network to see if the connection is successful. Configure other security settings. Change the WiFi password regularly to learn the route.

How to upgrade Win11 English 21996 to Simplified Chinese 22000_How to upgrade Win11 English 21996 to Simplified Chinese 22000 How to upgrade Win11 English 21996 to Simplified Chinese 22000_How to upgrade Win11 English 21996 to Simplified Chinese 22000 May 08, 2024 pm 05:10 PM

First you need to set the system language to Simplified Chinese display and restart. Of course, if you have changed the display language to Simplified Chinese before, you can just skip this step. Next, start operating the registry, regedit.exe, directly navigate to HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlNlsLanguage in the left navigation bar or the upper address bar, and then modify the InstallLanguage key value and Default key value to 0804 (if you want to change it to English en-us, you need First set the system display language to en-us, restart the system and then change everything to 0409) You must restart the system at this point.

How to find the update file downloaded by Win11_Share the location of the update file downloaded by Win11 How to find the update file downloaded by Win11_Share the location of the update file downloaded by Win11 May 08, 2024 am 10:34 AM

1. First, double-click the [This PC] icon on the desktop to open it. 2. Then double-click the left mouse button to enter [C drive]. System files will generally be automatically stored in C drive. 3. Then find the [windows] folder in the C drive and double-click to enter. 4. After entering the [windows] folder, find the [SoftwareDistribution] folder. 5. After entering, find the [download] folder, which contains all win11 download and update files. 6. If we want to delete these files, just delete them directly in this folder.

See all articles