I want to create an MariaDB instance where I have a user which can create and alter databases. This is my docker compose file:
version: '3.1'
services:
db:
image: mariadb
restart: always
environment:
MARIADB_ROOT_PASSWORD: example
MARIADB_USER: user
MARIADB_PASSWORD: example
command: >
bash -c echo "GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION;" mysql -u root -pexample -h localhost
volumes:
- C:\db-data:/var/lib/mysql
ports:
- "3306:3306"
adminer:
image: adminer
restart: always
ports:
- 8080:8080
I am getting the following error when executing "CREATE DATABASE DB;" from my python application running on the host system:
Access denied for user 'user'@'%' to database 'DB'
I can open a terminal and log into the database and grant privileges manually but I just want to run docker compose create/start and have everything ready. And I want to be able to create new databases from my python application as well. I have a bash command defined in my docker compose file in order to set privileges but it seems like it has not been ran.