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

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)

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

Why does using --acls and --xattrs together stop the mapping of ACL users from remote to local?

I'm trying to copy files and preserve EVERYTHING from a remote server to a local server where the same users exist, but with different IDs. By default, rsync should map the names correctly and this seems to be the case when --acls, -A is used, but not when also preserving extended attributes with --xattrs, -X:
Preserves ACLs and maps user names from remote to users on local:
sudo -E rsync -avzA --delete --rsync-path="sudo rsync" me#10.0.0.1:/var/www /var
# file: www/
# owner: root
# group: root
user::rwx
user:foo:r-x
group::r-x
group:www-data:r-x
mask::rwx
other::---
Preserves ACLs, but user name mapping does not work:
sudo -E rsync -avzAX --delete --rsync-path="sudo rsync" me#10.0.0.1:/var/www /var
# file: www/
# owner: root
# group: root
user::rwx
user:1006:r-x
group::r-x
group:cockpit:r-x
mask::rwx
other::---
Why does using --acls and --xattrs together stop the mapping of ACL users from remote to local?
rsync version 3.1.3 protocol version 31

Next cloud and mysql setup: authentication method unknown to the client

Using the rancher GUI, I'm trying to set up Nextcloud with MySQL database workloads on my AKS cluster. In the environment variables, I already have defined the admin user and password so why do I get this error on the create admin page?
Error while trying to create admin user: Failed to connect to the
database: An exception occurred in driver: SQLSTATE[HY000] [2054] The
server requested authentication method unknown to the client
I entered the Username and password correctly multiple times.
Below are my configurations for the database and nextcloud so far.
database workload:
Name: nextdb
Docker image: mysql
port: not set
I have the following variables:
MYSQL_ROOT_PASSWORD=rootpassX
MYSQL_DATABASE=nextDB
MYSQL_USER=nextcloud
MYSQL_PASSWORD=passX
volumes configuration:
Volume Type: Bind-Mount
Volume Name: nextdb
Path on the Node : /nextdb
The Path on the Node must be: a directory or create
Mount Point: /var/lib/mysql
nextcloud workload:
Name: nextcloud
Docker Image: nextcloud
Port Mapping:
Port Name : nextcloud80
Publish the container port: 80
Protocol: TCP
As a: Layer-4 load balancer
On listening port: 80
Environment variables:
MYSQL_DATABASE=nextDB
MYSQL_USER=nextcloud
MYSQL_PASSWORD=passX
MYSQL_HOST=nextdb
NEXTCLOUD_ADMIN_USER=admin
NEXTCLOUD_ADMIN_PASSWORD=adminPass
NEXTCLOUD_DATA_DIR=/var/www/html/nextcloud
Volumes:
Volume 1:
name: nextcloud
Volume Type: Bind-Mount
Path on the Node: /nextcloud
The Path on the Node must be: a directory or create.
Mount Point: /var/www/html
Volume 2
name: nextdb
Volume Type: Bind-Mount
Path on the Node: /nextdatabase
The Path on the Node must be: a directory or create.
Mount Point: /var/lib/mysql
What are the problems with my configurations?
Starting with version 8.02, MySQL updated the default authentication method for client connections. To revert to the older authentication method you need to explicitly specify the default authentication method.
If you are able to update your DB service in Rancher to pass the container argument --default-authentication-plugin=mysql_native_password that should revert MySQL to the older auth method.
Alternatively, depending on the MySQL image you are using, you can create a new Docker image from that base which replaces /etc/mysql/my.cnf inside the container. You should inspect /etc/mysql/my.cnf before you replace it, if there are any !includedir directives in the config file, you can place your supplemental configuration into an included folder using whatever filename you choose.
The supplemental configuration should look like this:
[mysqld]
default_authentication_plugin=mysql_native_password

MySQL in Docker on Windows: World-writable files ignored

I'm using Docker-Compose with the MySQL Image to fire up a MySQL database as part of a larger project.
As documented in the MySQL image's documentation, I'm mapping in a custom configuration file to /etc/mysql/conf.d/config-file.cnf:
database:
environment:
MYSQL_ROOT_PASSWORD: foo
ports:
- "3306:3306"
volumes:
- "./mysql/conf.d/:/etc/mysql/conf.d"
image: mysql:5.5
This works perfectly fine when running on Mac OS X as the host system (using docker-machine), but it fails when running on Windows (also using docker-machine). MySQL complains about the fact that the /etc/mysql/conf.d/config-file.cnf is world-writable
Warning: World-writable config file '/etc/mysql/conf.d/config-file.cnf' is ignored
When entering the database container, the file is indeed shown as having 0777 permission. This seems to be due to the host file system's permissions (Windows).
Is there any way to change this? I've tried mounting the volume in read-only mode, but the file still has the same permissions.
Any other way around this problem? At the moment, I'm mounting the file to another folder in the container and then copying/chmod'ing it to the required location as part of the startup command:
database:
environment:
MYSQL_ROOT_PASSWORD: foo
ports:
- "3306:3306"
volumes:
- "./mysql/conf.d/:/usr/local/mysqlconf"
image: mysql:5.5
command: >
bash -c "
cp /usr/local/mysqlconf/*.cnf /etc/mysql/conf.d/
&& chmod 644 /etc/mysql/conf.d/*.cnf
&& /entrypoint.sh mysqld
"
Is there a better way to solve this issue?
When you start up a container with -v, --volumes or use volumes: in docker-compose.yml
docker run -v source:/dest:rw busybox ls -l /dest
Docker mounts the source directory from the Linux VM into a container as /dest. Docker mounted volumes only provide their own options rw and r and I think z for selinux. Owner and permission info will be passed through to the container exactly as the Linux VM sees them. If someone who clones your repo runs docker or docker-compose from their local host rather than on the VM, they will mount blank directories.
Docker Machine's Users share
A docker-machine created local VM will share your computer's local users directory by default. C:\Users on Windows and /Users on OSX. This is done as a VirtualBox shared folder called Users. This share is then mounted on the Linux side via VirtualBox's vboxsf mount tool as /Users or maybe /c/Users via a Linux startup script /etc/rc.d/vbox.
When you docker-machine ssh default you should be able to see all your computers file at /Users/nwinkler.
This share allows docker-compose to reference a relative, local directory within C:\Users and have it work on the Linux VM. Outside of C:\Users the data doesn't exist on the VM.
World readable files
I believe what you are seeing is vboxsf's POSIX representation of a Windows file system. If you run:
docker-machine ssh default
$ cd /Users/nwinkler/path/to/mysql-docker
$ ls -l
$ docker run -v $PWD:/mysql busybox ls -l /mysql
You should see all your files as world writable. The only way to change the represented permissions is via the vboxsf mounted share.
The mount options vboxsf provides are:
Available mount options are:
rw mount writable (the default)
ro mount read only
uid=UID set the default file owner user id to UID
gid=GID set the default file owner group id to GID
ttl=TTL set the "time to live" to TID for the dentry
dmode=MODE override the mode of all directories to (octal) MODE
fmode=MODE override the mode of all regular files to (octal) MODE
umask=UMASK set the umask to (octal) UMASK
dmask=UMASK set the umask applied to directories only
fmask=UMASK set the umask applied to regular files only
iocharset CHARSET use the character set CHARSET for I/O operations
(default set is utf8)
convertcp CHARSET convert the folder name from CHARSET to utf8
On the Docker Linux VM, edit /etc/rc.d/box and append the options to the mountOptions variable. These options will apply to all files and directories under /Users on that mount.
You could set an fmask=007 to remove other permissions from all files or fmode=750 to override all permissions for all files.
mountOptions='defaults,iocharset=utf8'
if grep -q '^docker:' /etc/passwd; then
mountOptions="${mountOptions},uid=$(id -u docker),gid=$(id -g docker),fmask=007"
fi
If you ever upgrade or recreate your docker-machine VM you will need to do this again.
I tend to skip relying on virtualbox shares and have local files monitored and synchronised to my hosts on change (fsevents and rsync).

Can I change my.inf in OpenShift without root access?

I want to sync a local database with OpenShift MySQL, but I can't change my.inf because I don't have root access. Is it possible to get root access on OpenShift?
I believe you are interested in my.cnf. If you ssh into your gear (rhc ssh <yourApp>) and check the file (~/mysql/conf/my.cnf), you will see that it's owned by you, the root access is not needed.
However, if you check the beginning of the file, you will see:
# WARNING: Changes to this file will be lost on every restart/upgrade. Configurable values can be set with environment variables through rhc env set...
#
# Ex: rhc env set OPENSHIFT_MYSQL_LOWER_CASE_TABLE_NAMES=1 -a myapp && rhc cartridge restart -c mysql-5.5 -a myapp
#
# Configurable Values:
# lower_case_table_names -> OPENSHIFT_MYSQL_LOWER_CASE_TABLE_NAMES
# default-storage-engine -> OPENSHIFT_MYSQL_DEFAULT_STORAGE_ENGINE
# max_connections -> OPENSHIFT_MYSQL_MAX_CONNECTIONS
# ft_min_word_len -> OPENSHIFT_MYSQL_FT_MIN_WORD_LEN
# ft_max_word_len -> OPENSHIFT_MYSQL_FT_MAX_WORD_LEN
Which should answer your question on what is configurable and how to do it.

Starting MySql Cluster ndb_mgm

I am trying to start maysql cluster ndb_mgm,
but its giving me the following error,
my my.ini file is like this,
[mysql_cluster]
# Options for management node process
config-file=C:/mysql/bin/config.ini
what is meant by unknown variable
The MySQL Cluster global configuration file is by convention named config.ini (but this is not required). It is read by ndb_mgmd at startup and can be placed anywhere. Its location and name are specified by using --config-file=path_name on the ndb_mgmd command line. If the configuration file is not specified, ndb_mgmd by default tries to read a file named config.ini located in the current working directory .
# my.cnf
# example additions to my.cnf for MySQL Cluster
# provide location of cluster configuration file**
[ndb_mgmd]
config-file=/etc/config.ini
After saving the config.ini file, enter the following command to start the management server (the -f
option allows you to pass the location of the config.ini location):
ndb_mgmd -f /etc/config.ini
Start the management console by entering the following command:
ndb_mgm