I have MariaDB on docker
Trying to setup ssl I managed to completely break my user; I ended up with user duplicates and a new user called testssl
I tried resetting everything by deleting my database; deleting the image but nothing works. Every time I connect to the database and list users I get the same old list; testssl
is still there
Where are those settings stored and how do I reset MariaDB to a completely clean state on my docker?
app:
container_name: app
image: "${APP_IMAGE}"
restart: always
build: build/app
env_file: .env
networks:
- app_network
volumes:
- "${APP_HOST_DIR}:${APP_CONTAINER_DIR}"
depends_on:
- database
database:
container_name: mariadb
image: "mariadb:${MARIADB_VERSION}"
restart: always
env_file: .env
volumes:
- "${SQL_INIT}:/docker-entrypoint-initdb.d"
- type: bind
source: ${MARIADB_DATA_DIR}
target: /var/lib/mysql
- type: bind
source: ${MARIADB_LOG_DIR}
target: /var/logs/mysql
- type: bind
source: ${MARIADB_CERTS_DIR}
target: /etc/certs/
environment:
MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
MYSQL_DATABASE: "${MYSQL_DATABASE}"
MYSQL_USER: "${MYSQL_USER}"
MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
.env
MARIADB_DATA_DIR=./build/database/files/database
MARIADB_LOG_DIR=./build/database/files/logs
MARIADB_CERTS_DIR=./build/database/certs
2
Answers
MariaDB stores all of its runtime configuration (users, databases, etc.) in its data directory.
You’ve told your MariaDB container to use the host
build/database/files/database
directory for its data, so resetting the container won’t do much since the data is, well, there.Assuming the container is well-behaved and will initialize the database system if there’s nothing in the data directory, you should be able to move that
build/database/files/database
folder to e.g.build/database/files/database.old
, and create a new emptybuild/database/files/database
, then retry.If you are using docker volumes you can:
From
To
Restart docker services
docker-compose up -d
Remove previous volume (optional)
docker volume prune
This will install a fresh mariadb in the new volume and with docker volume prune if your previous volume is not used by another container it will be deleted