Root connexion to mariadb with a password

Hello
I want to use a password when connecting to maraiadb (mariadb -u root -p).
But with my code connexioon est ok without a pw (maraidb -u root)
I have thhe following .env :
MYSQL_ROOT_PASSWORD=123
MYSQL_DATABASE=wordpress
MYSQL_USER=wordpress_user
MYSQL_PASSWORD=123

WORDPRESS_DB_HOST=mariadb
WORDPRESS_DB_USER=wp_user
WORDPRESS_DB_PASSWORD=wp_password
WORDPRESS_DB_NAME=wordpress

I have bind mounts volumes.
The problem remains even after clearing the volumes content.
Any clue ?

1 Like

We need more context, just providing some env vars isn’t enough. What command or compose file do you use?

Thank you for your message.
My docker-compose.yml :slight_smile:
services:

mariadb:

build:

  context: ./requirements/mariadb

container_name: mariadb

image: mariadb

volumes:

  - /home/jfgeny/data/mariadb:/var/lib/mysql

networks:

  - inception

restart: always

healthcheck:

  test: ["CMD", "mysqladmin", "ping", "--socket=/run/mysqld/mysqld.sock"]

  interval: 10s

  timeout: 5s

  retries: 3

env_file:

  - ./.env        

wordpress:

build:

  context: ./requirements/wordpress

container_name: wordpress

image: wordpress

volumes:

  - /home/jfgeny/data/wordpress:/var/www/html

depends_on:

  mariadb:

    condition: service_healthy

networks:

  - inception

restart: always

healthcheck:

  test: ["CMD", "pidof", "php-fpm7.4"]

  interval: 30s

  timeout: 10s

  retries: 3

env_file:

  - ./.env  

nginx:

build:

  context: ./requirements/nginx

container_name: nginx

image: nginx

volumes:

  - /home/jfgeny/data/wordpress:/var/www/html

ports:

  - "443:443"

depends_on:

  wordpress:

    condition: service_healthy

healthcheck:

  test: ["CMD", "curl", "-k", "-f", "https://localhost/"]

  interval: 30s

  timeout: 10s

  retries: 3        

networks:

  - inception

restart: always

env_file:

  - ./.env      

networks:

inception:

driver: bridge

I sent an old .env (sorry). The right one :
MYSQL_ROOT_PASSWORD=123

MYSQL_DATABASE=wordpress

MYSQL_USER=wp_user

MYSQL_PASSWORD=123

WORDPRESS_DB_HOST=mariadb

WORDPRESS_DB_USER=wp_user

WORDPRESS_DB_PASSWORD=123

WORDPRESS_DB_NAME=wordpress

This looks strange, is this a single compose file? What`s with all the line-breaks?

The combined use of build: and image: is also strange, you build your own images with a custom Dockerfile for each or want to use public images?

I checked the “image” problem on the net.
It is said that if I have a build before, “image:…” is just here to give a name to your image and not fetching a public image from dockhub.

So is the problem solved?

If not. Please post the compose file content as a single code block. Back sure to use ``` in a separate line before and after the content, so that it appears as code block.

There is no joy in looking at a compose file, where indentation maters a lot, that is not properly formatted.

Thank you for your message.
I solved the problem after lot of pain and sweat.
Next time I will not forget the ```

Could you please still post your corrected compose file?

It might help someone else who is in the same situation, but doesn’t know how to solve it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.