Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Docker - MariaDB - Access denied

Hello,

I have a rights issue with MariaDB inside docker.

mariadb:
  image: mariadb:10.7
  container_name: yggdra-mariadb
  ports:
    - 3306:3306
  environment:
    MYSQL_ROOT_PASSWORD: musiqueYggdra
    MYSQL_ROOT_HOST: '%'
    MYSQL_HOST: mariadb
    MYSQL_DATABASE: myproject
    MYSQL_USER: myproject
    MYSQL_PASSWORD: mypassword
    MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
  volumes:
    - ./mysql:/var/lib/mysql
  restart: unless-stopped

When I try to login with phpmyadmin or ever when I try to migrate the database, I get an error : access denied for user myproject.

Several cases are reported in several posts on the web, I have tried all what I can try for some hours, but it doesn't work better.

Can you help me solve this issue please ?

Thanks a lot.

V

0 likes
4 replies
Tray2's avatar

Have you created that user in the database?

1 like
vincent15000's avatar

@Tray2 No ... but seeing the docker series by Andrew Schmelyun on Laracast, it seems to be created automatically just via the environment variables.

Now I'm not sure ...

vincent15000's avatar

@Tray2 Hmmm ... now I'm sure, the user is automatically created in the database ... I don't have done anything else than specifying the username and the passwork inside the docker-compose.yml file and the user is automatically created.

It works with the tutorial ... but not in my other project.

vincent15000's avatar
vincent15000
OP
Best Answer
Level 63

All what I had done was correct.

I solved this by removing entirely the local mysql folder and recreated it empty.

And it works fine.

So the problem was probably that the mariadb database was previously initialized with some configuration and due to security, any further modification via new docker containers was not possible.

Please or to participate in this conversation.