Docker Official Image Frequently Asked Questions
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:
Adjust myuser
, databasename
and passwords as needed.
Then:
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:
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.
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:
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:
Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler.
This will show up in the container log as:
The cause is the underlying table has change structure from the last MariaDB version. The easiest solution to this is to start the container with the environment variable MARIADB_AUTO_UPGRADE=1 and system tables will be updated. This is safe to keep on as it detects the version installed. The next start should not show this error.
InnoDB: Upgrade after a crash is not supported. The redo log was created with MariaDB X.Y.Z
This will show up in the error log as:
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:
After you see this, you can update your MariaDB tag to a later version.
Every MariaDB start gives permission denied messages
Or:
In this case, the container is running as a user that, inside the container, does not have write permissions on the datadir /varlib/mysql
.
Bad magic header in tc log
From the transaction coordinator log this is a corrupted file. This will have a log message like the following:
The cause of this is headed by the first not, its a crash recovery. Like the Every MariaDB start is a crash recovery answer below, this is an indication that MariaDB wasn't given enough time by the container runtime to shutdown cleanly. While MariaDB was shutdown, the new version that was started is a newer MariaDB and doesn't recognise the updated magic information in the header.
MariaDB should always perform crash recovery with the same version that actually crashed, the same major/minor number at least.
As such the solution is to restart the container with the previous MariaDB version that was running, and configure the container runtime to allow a longer stop time. See the Every MariaDB start is a crash recovery answer below to see if the timeout is sufficiently extended.
Every MariaDB start is a crash recovery
Do you get on every start:
Container runtimes are assume to start and stop very quickly. Check the the shutdown logs. They may be a log like:
Note that the logs didn't include the following messages:
As these messages aren't here, the container was killed off before it could just down cleanly. When this happens, the startup will be a crash recovery and you won't be able to upgrade your MariaDB instance (previous FAQ) to the next Major.Minor version.
Solution is to extend the timeout in the container runtime to allow MariaDB to complete its shutdown.
How do I create a MariaDB-backup of the data?
How do I restore from a MariaDB-backup
With the backup prepared like previously:
How to start MariaDB with Apptainer
Because Apptainer has all the filesystems readonly except or the volume, the /run/mysqld directory is used as a pidfile and socket directory. An easy way is to mark this as a scratch directory.
Alternately:
Why does the MariaDB container start as root?
The MariaDB entrypoint briefly starts as root, and if a explicit volume is there, the owner of this volume will be root. To allow MariaDB to use the CHOWN capability to change to the volume owner to a user that can write to this volume, it needs to be briefly root. After this one action is taken, the entrypoint uses gosu to drop to a non-root user and continues execution. There is no accessible exploit vector to remotely affect the container startup when it is briefly running as the root user.
Can I run the MariaDB container as an arbitrary user?
Yes. using the user: 2022 in a compose file, or --user 2022 as a command will run the entrypoint as the user id 2022. When this occurs, it is assumed that the volume of the datadir has the right permissions for MariaDB to access the datadir. This can be useful if your local user is user id 2022 and your datadir is owned locally by this user. Note inside the container there isn't the same user names outside the container defined, so working with numbers is more portable.
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?