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

Viewed 615

I want to change the default MySQL username and password either during setup or after.

I've tried a bit of a scattershot approach and changed every config file I can find with username and password, but still doesn't work.

Files I've edited below:

> ~/.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

Error during rebuild:

> 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)
2 Answers

From the FAQ of the official guide:

How can I change the docker containers configuration?

You can copy the file /conf/dist/.env.docker to .env and place it in the root folder of the project, then edit it according to your needs.

In the .env file you can configure:

  • the location of the data, etc and logs folders
  • the open ports
  • the MySQL root password

Then your docker-compose up will automatically locate the .env with your custom settings.

Okay got this sorted out, here's the solution.

You can copy the file /conf/dist/.env.docker to .env and place it in the root folder of the project, then edit it according to your needs.

In the .env file you can configure:

  • the location of the data, etc and logs folders
  • the open ports
  • the MySQL root password

Then your docker-compose up will automatically locate the .env with your custom settings.

.env file:

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

...

Note: Apparently there is an unresolved issue with using a # in password so dont.

..\azerothcore-wotlk\conf\dist\

env.ac file:

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 file:

###############################################
# 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
Related