You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mariadb/README.md
+150-3Lines changed: 150 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -160,10 +160,10 @@ This will start a new container `some-mariadb` where the MariaDB instance uses t
160
160
161
161
### Configuration without a `cnf` file
162
162
163
-
Many configuration options can be passed as flags to `mysqld`. This will give you the flexibility to customize the container without needing a `cnf` file. For example, if you want to change the default encoding and collation for all tables to use UTF-8 (`utf8mb4`) just run the following:
163
+
Many configuration options can be passed as flags to `mysqld`. This will give you the flexibility to customize the container without needing a `cnf` file. For example, if you want to run on port 3808 just run the following:
If you would like to see a complete list of available options, just run:
@@ -222,7 +222,7 @@ Currently, this is only supported for `MARIADB_ROOT_PASSWORD`, `MARIADB_ROOT_HOS
222
222
223
223
# Initializing a fresh instance
224
224
225
-
When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions `.sh`, `.sql`, `.sql.gz`, and `.sql.xz` that are found in `/docker-entrypoint-initdb.d`. Files will be executed in alphabetical order. `.sh` files without file execute permission are sourced rather than executed. You can easily populate your `mariadb` services by [mounting a SQL dump into that directory](https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-file-as-a-data-volume) and provide [custom images](https://docs.docker.com/reference/builder/) with contributed data. SQL files will be imported by default to the database specified by the `MARIADB_DATABASE` / `MYSQL_DATABASE` variable.
225
+
When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions `.sh`, `.sql`, `.sql.gz`, `.sql.xz` and `.sql.zst` that are found in `/docker-entrypoint-initdb.d`. Files will be executed in alphabetical order. `.sh` files without file execute permission are sourced rather than executed. You can easily populate your `mariadb` services by [mounting a SQL dump into that directory](https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-file-as-a-data-volume) and provide [custom images](https://docs.docker.com/reference/builder/) with contributed data. SQL files will be imported by default to the database specified by the `MARIADB_DATABASE` / `MYSQL_DATABASE` variable.
226
226
227
227
# Caveats
228
228
@@ -268,6 +268,153 @@ For restoring data. You can use the `docker exec` command with the `-i` flag, si
268
268
$ docker exec -i some-mariadb sh -c 'exec mysql -uroot -p"$MARIADB_ROOT_PASSWORD"' < /some/path/on/your/host/all-databases.sql
269
269
```
270
270
271
+
## Creating backups with Mariabackup
272
+
273
+
To perform a backup using Mariabackup, an additional volume for the backup needs to be included when the container is started like this:
If you wish to take a copy of the `/backup` you can do so without stopping the container or getting an inconsistent backup.
292
+
293
+
```console
294
+
$ docker exec --user mysql some-mariadb tar --create --xz --file - /backup > backup.tar.xz
295
+
```
296
+
297
+
## Restore backups with Mariabackup
298
+
299
+
These steps restore the backup made with Mariabackup.
300
+
301
+
At some point before doing the restore, the backup needs to be prepared. Here `/my/own/backupdir` contains a previous backup. Perform the prepare like this:
302
+
303
+
```console
304
+
$ docker run --user mysql --rm -v /my/own/backupdir:/backup mariadb:latest mariabackup --prepare --target-dir=/backup
305
+
```
306
+
307
+
Now that the image is prepared, start the container with both the data and the backup volumes and restore the backup:
308
+
309
+
```console
310
+
$ docker run --user mysql --rm -v /my/own/newdatadir:/var/lib/mysql -v /my/own/backupdir:/backup mariadb:latest mariabackup --copy-back --target-dir=/backup
311
+
```
312
+
313
+
With `/my/own/newdatadir` containing the restored backup, start normally as this is an initialized data directory:
314
+
315
+
```console
316
+
$ docker run --name some-mariadb -v /my/own/newdatadir:/var/lib/mysql -d mariadb:latest
317
+
```
318
+
319
+
For further information on Mariabackup, see the [Mariabackup Knowledge Base](https://mariadb.com/kb/en/mariabackup-overview/).
320
+
321
+
## How to reset root and user passwords
322
+
323
+
If you have an existing data directory and wish to reset the root and user passwords, and to create a database on which the user can fully modify, perform the following steps.
324
+
325
+
First create a `passwordreset.sql` file:
326
+
327
+
```text
328
+
CREATE USER IF NOT EXISTS root@localhost IDENTIFIED BY 'thisismyrootpassword';
329
+
SET PASSWORD FOR root@localhost = PASSWORD('thisismyrootpassword');
330
+
GRANT ALL ON *.* TO root@localhost WITH GRANT OPTION;
331
+
CREATE USER IF NOT EXISTS root@'%' IDENTIFIED BY 'thisismyrootpassword';
332
+
SET PASSWORD FOR root@'%' = PASSWORD('thisismyrootpassword');
333
+
GRANT ALL ON *.* TO root@'%' WITH GRANT OPTION;
334
+
CREATE USER IF NOT EXISTS myuser@'%' IDENTIFIED BY 'thisismyuserpassword';
335
+
SET PASSWORD FOR myuser@'%' = PASSWORD('thisismyuserpassword');
336
+
CREATE DATABASE IF NOT EXISTS databasename;
337
+
GRANT ALL ON databasename.* TO myuser@'%';
338
+
```
339
+
340
+
Adjust `myuser`, `databasename` and passwords as needed.
341
+
342
+
Then:
343
+
344
+
```console
345
+
$ docker run --rm -v /my/own/datadir:/var/lib/mysql -v /my/own/passwordreset.sql:/passwordreset.sql:z mariadb:latest --init-file=/passwordreset.sql
346
+
```
347
+
348
+
On restarting the MariaDB container on this `/my/own/datadir`, the `root` and `myuser` passwords will be reset.
349
+
350
+
## How to install MariaDB plugins
351
+
352
+
MariaDB has many plugins, most are not enabled by default, some are in the mariadb container, others need to be installed from additional packages.
353
+
354
+
The following methods summarize the [MariaDB Blog article - Installing plugins in the MariaDB Docker Library Container](https://mariadb.org/installing-plugins-in-the-mariadb-docker-library-container/) on this topic.
355
+
356
+
### Which plugins does the container contain?
357
+
358
+
To see which plugins are available in the mariadb:
359
+
360
+
```console
361
+
$ docker run --rm mariadb:latest ls -C /usr/lib/mysql/plugin
362
+
```
363
+
364
+
### Enabling a plugin using flags
365
+
366
+
Using the `--plugin-load-add` flag with the plugin name (can be repeated), the plugins will be loaded and ready when the container is started:
367
+
368
+
For example enable the `simple\_password\_check` plugin:
`plugin-load-add`can be used as a configuration option to load plugins. The example below load the [FederatedX Storage Engine](https://mariadb.com/kb/en/federatedx-storage-engine/).
In this case the `my\_initdb` is a `/docker-entrypoint-initdb.d` directory per "Initializing a fresh instance" section above.
394
+
395
+
### Identifing additional plugins in additional packages
396
+
397
+
A number of plugins are in separate packages to reduce their installation size. The package names of MariaDB created plugins can be determined using the following command:
398
+
399
+
```console
400
+
$ docker run --rm mariadb:latest sh -c 'apt-get update -qq && apt-cache search mariadb-plugin'
401
+
```
402
+
403
+
### Creating a image with plugins from additional packages
404
+
405
+
A new image needs to be created when using additional packages. The mariadb image can be used as a base however:
406
+
407
+
In the following the [CONNECT Storage Engine](https://mariadb.com/kb/en/connect/) is installed:
408
+
409
+
```dockerfile
410
+
FROM mariadb:latest
411
+
RUN apt-get update && \
412
+
apt-get install mariadb-plugin-connect -y && \
413
+
rm -rf /var/lib/apt/lists/*
414
+
```
415
+
416
+
Installing plugins from packages creates a configuration file in the directory `/etc/mysql/mariadb.conf.d/` that loads the plugin on startup.
417
+
271
418
# License
272
419
273
420
View [license information](https://mariadb.com/kb/en/library/licensing-faq/) for the software contained in this image.
0 commit comments