gpt4 book ai didi

php - docker-compose mysql环境PASSWORD和ROOT_PASSWORD的区别

转载 作者:行者123 更新时间:2023-12-01 12:14:55 28 4
gpt4 key购买 nike

这是来自我的 docker compose:

 db:
image: mysql
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: myDb
MYSQL_USER: user
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: test
volumes:
- ./dump:/docker-entrypoint-initdb.d
- persistent:/var/lib/mysql

当我将我的用户和两个密码都更改为“root”时,我的数据库被创建但它是空的。当我按上述方式保留凭据时,/dump 目录中的 .sql 脚本会按预期填充数据库。凭据更改如何影响数据注入(inject),我该如何解决?

最佳答案

从文档(https://hub.docker.com/_/mysql/)...

MYSQL_USER, MYSQL_PASSWORD

These variables are optional, used in conjunction to create a new user and to set that user's password. This user will be granted superuser permissions (see above) for the database specified by the MYSQL_DATABASE variable. Both variables are required for a user to be created.



所以这是创建一个带有密码的新用户。 MYSQL_ROOT_PASSWORD 是 MySQL 的 root 用户的密码。

MYSQL_ROOT_PASSWORD This variable is mandatory and specifies the password that will be set for the MySQL root superuser account. In the above example, it was set to my-secret-pw.

关于php - docker-compose mysql环境PASSWORD和ROOT_PASSWORD的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49197640/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com