Docker Official Image Frequently Asked Questions
See MariaDB and Docker in action!
- Set up web-based developer environments locally, and connect MariaDB to VS Code Server, CloudBeaver, PHP/Laravel and phpMyAdmin, using a single docker-compose command and configuration file.
Contents
Frequently asked questions about the Docker Official Image
How to Reset Passwords
If you have an existing data directory and wish to reset the root and user passwords, and to create a database which the user can fully modify, perform the following steps.
First create a `passwordreset.sql` file:
CREATE USER IF NOT EXISTS root@localhost IDENTIFIED BY 'thisismyrootpassword'; SET PASSWORD FOR root@localhost = PASSWORD('thisismyrootpassword'); GRANT ALL ON *.* TO root@localhost WITH GRANT OPTION; GRANT PROXY ON ''@'%' ON root@localhost WITH GRANT OPTION; CREATE USER IF NOT EXISTS root@'%' IDENTIFIED BY 'thisismyrootpassword'; SET PASSWORD FOR root@'%' = PASSWORD('thisismyrootpassword'); GRANT ALL ON *.* TO root@'%' WITH GRANT OPTION; GRANT PROXY ON ''@'%' ON root@'%' WITH GRANT OPTION; CREATE USER IF NOT EXISTS myuser@'%' IDENTIFIED BY 'thisismyuserpassword'; SET PASSWORD FOR myuser@'%' = PASSWORD('thisismyuserpassword'); CREATE DATABASE IF NOT EXISTS databasename; GRANT ALL ON databasename.* TO myuser@'%';
Adjust `myuser`, `databasename` and passwords as needed.
Then:
$ docker run --rm -v /my/own/datadir:/var/lib/mysql -v /my/own/passwordreset.sql:/passwordreset.sql:z %%IMAGE%%:latest --init-file=/passwordreset.sql
On restarting the MariaDB container in this `/my/own/datadir`, the `root` and `myuser` passwords will be reset.
Temp Server Start Timeout
Question, are you getting errors like the following where a temporary server start fails to succeed in 30 seconds?
Example of log:
2023-01-28 12:53:42+00:00 [Note] [Entrypoint]: Starting temporary server 2023-01-28 12:53:42+00:00 [Note] [Entrypoint]: Waiting for server startup 2023-01-28 12:53:42 0 [Note] mariadbd (server 10.10.2-MariaDB-1:10.10.2+maria~ubu2204) starting as process 72 ... .... 2023-01-28 12:53:42 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ... 2023-01-28 12:54:13 0 [Note] mariadbd: ready for connections. Version: '10.10.2-MariaDB-1:10.10.2+maria~ubu2204' socket: '/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution 2023-01-28 12:54:13+00:00 [ERROR] [Entrypoint]: Unable to start server.
The timeout on a temporary server start is a quite generous 30 seconds.
The lack of a message like the following indicates it failed to complete writing a temporary file of 12MiB in 30 seconds.
2023-01-28 12:53:46 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
If the datadir where this is stored is remote storage maybe it's a bit slow. It's ideal to have an InnoDB temporary path local so this can be configured using the command or configuration setting:
innodb_temp_data_file_path=/dev/shm/ibtmp1:12M:autoextend
Note: depending on container runtime this space may be limited.
Creating a replication pair
`MARIADB_REPLICATION_USER` / `MARIADB_REPLICATION_PASSWORD` specify the authentication for the connection. The `MARIADB_MASTER_HOST` is the indicator that it is a replica and specifies the container aka hostname, of the master.
A `docker-compose.yml` example:
version: "3" services: master: image: mariadb:latest command: --log-bin --log-basename=mariadb environment: - MARIADB_ROOT_PASSWORD=password - MARIADB_USER=testuser - MARIADB_PASSWORD=password - MARIADB_DATABASE=testdb - MARIADB_REPLICATION_USER=repl - MARIADB_REPLICATION_PASSWORD=replicationpass healthcheck: test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] interval: 10s timeout: 5s retries: 3 replica: image: mariadb:latest command: --server-id=2 --log-basename=mariadb environment: - MARIADB_ROOT_PASSWORD=password - MARIADB_MASTER_HOST=master - MARIADB_REPLICATION_USER=repl - MARIADB_REPLICATION_PASSWORD=replicationpass - MARIADB_HEALTHCHECK_GRANTS=REPLICA MONITOR healthcheck: test: ["CMD", "healthcheck.sh", "--connect", "--replication_io", "--replication_sql", "--replication_seconds_behind_master=1", "--replication"] interval: 10s timeout: 5s retries: 3 depends_on: master: condition: service_healthy
InnoDB: Upgrade after a crash is not supported. The redo log was created with MariaDB 10.5.4
This is attempting to start on a higher MariaDB version when the shutdown of the previous version crashed.
By crashed, it means the MariaDB was force killed or had a hard power failure. MariaDB, being a durable database, can recover from these, if started with the same version. The redo log however is a less stable format, so the recovery has to be on the same Major.Minor version, in this case 10.5. This error message is saying that you when from force killed MariaDB to a later version.
So whenever you encounter this message. Start with the again with the tag set to the version in the error message, like 10.5.4, or as the redo long format is consistent in the Major.Minor version 10.5 is sufficient. After this has been started correctly, cleanly shut the service down and it will be recovered.
The logs on shutdown should have a message like:
2023-11-06 10:49:23 0 [Note] InnoDB: Shutdown completed; log sequence number 84360; transaction id 49 2023-11-06 10:49:23 0 [Note] mariadbd: Shutdown complete
After you see this, you can update your MariaDB tag to a later version.