Skip to main content

Change Default Password for Redis

tip
  • The following steps use the new password of Redis as f8K5ZT3aQXTb as an example. The Redis password must be modified in the actual configuration

    • To ensure compatibility, avoid using special characters such as "$", "&", "!" or "@" when customizing passwords. These characters may interfere with regular expression parsing. Please use hyphens "-" or underscores "_" instead
  • It is recommended to data backup in advance before operation.

  • The microservice version needs to be greater than v3.7.0 or above

  1. Enter the mingdaoyun-sc container and log in to Redis

    docker exec -it $(docker ps | grep mingdaoyun-sc | awk '{print $1}') bash -c 'redis-cli -a 123456'
  2. Modify Redis password

    config set requirepass f8K5ZT3aQXTb
  3. Modify the docker-compose.yaml file and add environment variables and port mapping

    Default path of docker-compose.yaml file: /data/mingdao/script/docker-compose.yaml

    Add the environment variable ENV_REDIS_PASSWORD under the core service to specify the new password for Redis

    ENV_REDIS_PASSWORD: "f8K5ZT3aQXTb"

Add a new port mapping under the sc service and map the 6379 port in the container (if external access is not required, you do not need to add port mapping)

- 6379:6379
docker-compose.yaml configuration file example
version: '3'

services:
core:
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-core:7.4.2
environment:
ENV_ADDRESS_MAIN: "https://example.domain.com"
ENV_APP_VERSION: "7.4.2"
ENV_API_TOKEN: "****"
ENV_REDIS_PASSWORD: "f8K5ZT3aQXTb" #Add a new variable and change it to the actual password.
ports:
- 8880:8880
volumes:
- ../data:/data/mingdao/data

sc:
image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-sc:3.2.0
environment:
<<: *app-environment
ports:
- 3306:3306 #Added Redis port mapping. If external access to Redis is not required, there is no need to add this port mapping.
volumes:
- ./volume/data/:/data/
- ../data:/data/mingdao/data
  1. Restart the microservice in the directory where the installation manager is located to take effect.

    bash service.sh restartall