'Applications can only connect using root password (MariaDB)

I have set up a Docker-compose that starts multiple applications. Basically it comes down to all the applications being able to connect to the MariaDB container/database.

Within MariaDB there's a variable called MYSQL_ROOT_PASSWORD to change the root password. But whenever I change it and use that password with let's say Wordpress I'm getting access denied errors. But when I then switch the password Wordpress is using back to just 'root', it works.

I hope someone can tell me what I'm doing wrong! :)

Here is my docker-compose.yml:

version: "3.2"

services:

    mariadb:
        image: "mariadb"
        container_name: mariadb
        volumes: 
            - "./mariadb:/var/lib/mysql"
        networks:
            - front
        environment: 
            - MYSQL_DATABASE=mariadb
            - MYSQL_USER=mariadb
            - MYSQL_PASSWORD=mariadb
            - MYSQL_ROOT_PASSWORD=321verysecurerootpassword123

    wordpress: 
        depends_on: 
            - mariadb
        image: "wordpress"
        container_name: wordpress
        links:
            - 'mariadb:mysql'
        volumes:
            - "./wordpress/:/var/www/html"
        networks:
            - front
        ports: 
            - "80:80"
        environment: 
            WORDPRESS_DB_PASSWORD: root

    firefly: 
        depends_on: 
            - mariadb
        image: "jc5x/firefly-iii:latest"
        container_name: firefly
        networks:
            - front
        ports:
            - "8080:8080"
        volumes:
            - "./firefly:/var/www/html/storage/upload"
        environment: 
            - APP_KEY=dRZ1lRipw1htgeanQrmjRcD3PGGJjvlk
            - DB_CONNECTION=mysql
            - DB_DATABASE=firefly
            - DB_USERNAME=root
            - DB_PASSWORD=root
            - DB_HOST=mariadb
            - DB_PORT=3306

    orangehrm:
        depends_on: 
            - mariadb
        image: "docker.io/bitnami/orangehrm:4-debian-10"
        container_name: orangehrm
        networks:
            - front
        ports: 
            - "8081:80"
            - "443:443"
        volumes:
            - "./orangehrm:/bitnami"
        environment: 
            ORANGEHRM_DATABASE_NAME: orangehrm
            ORANGEHRM_DATABASE_USER: root
            ORANGEHRM_DATABASE_PASSWORD: root
            ORANGEHRM_USERNAME: orangehrmuser
            ORANGEHRM_PASSWORD: orangehrmpassword

networks:
    front:
        external: false


Solution 1:[1]

I found the answer already.

I can't change the password on-the-go, I had to remove the old volume that MariaDB and Wordpress were using and re-create them. Then it works.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 studentinneedofhelp23