如何使用 docker 设置更改默认 MySQL 用户名和密码?

How to change default MySQL username and password using docker setup?

我想在设置期间或之后更改默认的 MySQL 用户名和密码。

我尝试了一些漫无目的的方法,并用用户名和密码更改了我能找到的每个配置文件,但仍然不起作用。

我在下面编辑的文件:

> ~/.env
> ~/conf/dist/env.ac 
> ~/conf/dist/env.docker
> ~/conf/config.sh
> ~/env/docker/etc/authserver.conf.dockerdist
> ~/env/docker/etc/worldserver.conf.dockerdist
> ~/docker-compose.yml

重建时出错:

> Searching on /azerothcore/data/sql/custom/db_world/ ...
> =====           DONE            =====
> =====       CHECKING DBs        ===== ERROR 1045 (28000): Access denied for user 'wowadmin'@'172.19.0.3' (using password: YES)

来自 the official guideFAQ

如何更改 docker 容器配置?

您可以将文件/conf/dist/.env.docker复制到.env并放在项目的根文件夹中,然后根据您的需要进行编辑。

.env文件中你可以配置:

  • 数据等位置和日志文件夹
  • 开放的端口
  • MySQLroot密码

然后您的 docker-compose up 将自动使用您的自定义设置找到 .env

好的,解决了这个问题,这是解决方案。

您可以将文件/conf/dist/.env.docker复制到.env中,放在项目的根目录下,然后根据需要进行编辑。

在.env文件中可以配置:

  • 数据等位置和日志文件夹
  • 开放的端口
  • MySQLroot密码

然后您的 docker-compose up 将自动找到具有您的自定义设置的 .env。

.env 文件:

DOCKER_AC_ENV_FILE=C:\Games\WoW-WotLK-Server\azerothcore-wotlk\conf\dist\env.ac
    
DOCKER_VOL_DATA=
DOCKER_VOL_ETC=
DOCKER_VOL_LOGS=
DOCKER_VOL_CONF=

DOCKER_WORLD_EXTERNAL_PORT=
DOCKER_SOAP_EXTERNAL_PORT=
DOCKER_AUTH_EXTERNAL_PORT=
DOCKER_DB_EXTERNAL_PORT=

DOCKER_DB_ROOT_PASSWORD=yourpassword

...

注意:显然在密码中使用 # 存在未解决的问题,所以不要。

..\azerothcore-wotlk\conf\dist\

env.ac 文件:

DB_AUTH_CONF=MYSQL_USER='root'; MYSQL_PASS='yourpassword'; MYSQL_HOST='ac-database'; MYSQL_PORT='3306';

DB_CHARACTERS_CONF=MYSQL_USER='root'; MYSQL_PASS='yourpassword'; MYSQL_HOST='ac-database'; MYSQL_PORT='3306';

DB_WORLD_CONF=MYSQL_USER='root'; MYSQL_PASS='yourpassword'; MYSQL_HOST='ac-database'; MYSQL_PORT='3306';

..\azerothcore-wotlk\env\docker\etc

authserver.conf 文件:

###############################################
# AzerothCore Auth Server configuration file #
###############################################
[authserver]

# Do not change this
# Files in LogsDir will reflect on your host directory: docker/authserver/logs
LogsDir = "/azerothcore/env/dist/logs"

# Change this configuration accordingly with your docker setup
# The format is "hostname;port;username;password;database":
# - docker containers must be on the same docker network to be able to communicate
# - the DB hostname will be the name of the database docker container
LoginDatabaseInfo = "ac-database;3306;root;yourpassword;acore_auth"

# Add more configuration overwrites by copying settings from from authserver.conf.dist
LogLevel = 3
SQLDriverLogFile = "SQLDriver.log"
SQLDriverQueryLogging = 1

worldserver.conf:

################################################
        # AzerothCore World Server configuration file #
        ################################################
        [worldserver]
        
        # Do NOT change those Dir configs
        # Files in LogsDir will reflect on your host directory: docker/worldserver/logs
        LogsDir = "/azerothcore/env/dist/logs"
        DataDir = "/azerothcore/env/dist/data"
        
        # Change this configuration accordingly with your docker setup
        # The format is "hostname;port;username;password;database":
        # - docker containers must be on the same docker network to be able to communicate
        # - the DB hostname will be the name of the database docker container
        LoginDatabaseInfo     = "ac-database;3306;root;yourpassword;acore_auth"
        WorldDatabaseInfo     = "ac-database;3306;root;yourpassword;acore_world"
        CharacterDatabaseInfo = "ac-database;3306;root;yourpassword;acore_characters"
        
        # Add more configuration overwrites by copying settings from worldserver.conf.dist
        LogLevel = 2
        
        # Disable idle connections automatic kick since it doesn't work well on macOS + Docker
    CloseIdleConnections = 0