Git Product home page Git Product logo

alpine-mariadb's Introduction

MariaDB Container image running on Alpine Linux

Docker Automated build Docker Pulls Docker Stars

Alpine Version MariaDB Version

This Container image (yobasystems/alpine-mariadb) is based on the minimal Alpine Linux with MariaDB v10.11.6 (MySQL Compatible) database server.

Alpine Version 3.19.1 (Released 2023-01-26)

MariaDB Version 10.11.6

Table of Contents

πŸ”οΈ What is Alpine Linux?

Alpine Linux is a Linux distribution built around musl libc and BusyBox. The image is only 5 MB in size and has access to a package repository that is much more complete than other BusyBox based images. This makes Alpine Linux a great image base for utilities and even production applications. Read more about Alpine Linux here and you can see how their mantra fits in right at home with Container images.

What is MariaDB?

MariaDB Server is one of the most popular database servers in the world. It’s made by the original developers of MySQL and guaranteed to stay open source. Notable users include Wikipedia, WordPress.com and Google.

MariaDB turns data into structured information in a wide array of applications, ranging from banking to websites. It is an enhanced, drop-in replacement for MySQL. MariaDB is used because it is fast, scalable and robust, with a rich ecosystem of storage engines, plugins and many other tools make it very versatile for a wide variety of use cases.

MariaDB is developed as open source software and as a relational database it provides an SQL interface for accessing data. The latest versions of MariaDB also include GIS and JSON features.

✨ Features

  • Minimal size only, minimal layers
  • Memory usage is minimal on a simple install.
  • MariaDB the MySQL replacement

πŸ—οΈ Architectures

  • :amd64, :x86_64 - 64 bit Intel/AMD (x86_64/amd64)
  • :arm64v8, :aarch64 - 64 bit ARM (ARMv8/aarch64)
  • :arm32v7, :armhf - 32 bit ARM (ARMv7/armhf)

πŸ“ PLEASE CHECK TAGS BELOW FOR SUPPORTED ARCHITECTURES, THE ABOVE IS A LIST OF EXPLANATION

🏷️ Tags

  • :latest latest branch based (Automatic Architecture Selection)
  • :master master branch usually inline with latest
  • :amd64, :x86_64 amd64 based on latest tag but amd64 architecture
  • :aarch64, :arm64v8 Armv8 based on latest tag but arm64 architecture
  • :armhf, :arm32v7 Armv7 based on latest tag but arm32 architecture
  • :version Version tags e.g :10, :10.11, 10.11.6

πŸ“ Layers & Sizes

Version MicroBadger Layers (tag) MicroBadger Size (tag)

Version MicroBadger Layers (tag) MicroBadger Size (tag)

Version MicroBadger Layers (tag) MicroBadger Size (tag)

πŸš€ How to use this image

Volume structure

  • /var/lib/mysql: Database files
  • /var/lib/mysql/mysql-bin: MariaDB logs

Environment Variables:

Main Mariadb parameters:

  • MYSQL_DATABASE: specify the name of the database
  • MYSQL_USER: specify the User for the database
  • MYSQL_PASSWORD: specify the User password for the database
  • MYSQL_ROOT_PASSWORD: specify the root password for Mariadb
  • MYSQL_CHARSET: default charset (utf8) for Mariadb
  • MYSQL_COLLATION: default collation (utf8_general_ci) for Mariadb

List of Character Sets & information

When setting charset, also make sure to choose a collation otherwise it will be the default.

+----------+-----------------------------+---------------------+--------+
| Charset  | Description                 | Default collation   | Maxlen |
+----------+-----------------------------+---------------------+--------+
| big5     | Big5 Traditional Chinese    | big5_chinese_ci     |      2 |
| dec8     | DEC West European           | dec8_swedish_ci     |      1 |
| cp850    | DOS West European           | cp850_general_ci    |      1 |
| hp8      | HP West European            | hp8_english_ci      |      1 |
| koi8r    | KOI8-R Relcom Russian       | koi8r_general_ci    |      1 |
| latin1   | cp1252 West European        | latin1_swedish_ci   |      1 |
| latin2   | ISO 8859-2 Central European | latin2_general_ci   |      1 |
| swe7     | 7bit Swedish                | swe7_swedish_ci     |      1 |
| ascii    | US ASCII                    | ascii_general_ci    |      1 |
| ujis     | EUC-JP Japanese             | ujis_japanese_ci    |      3 |
| sjis     | Shift-JIS Japanese          | sjis_japanese_ci    |      2 |
| hebrew   | ISO 8859-8 Hebrew           | hebrew_general_ci   |      1 |
| tis620   | TIS620 Thai                 | tis620_thai_ci      |      1 |
| euckr    | EUC-KR Korean               | euckr_korean_ci     |      2 |
| koi8u    | KOI8-U Ukrainian            | koi8u_general_ci    |      1 |
| gb2312   | GB2312 Simplified Chinese   | gb2312_chinese_ci   |      2 |
| greek    | ISO 8859-7 Greek            | greek_general_ci    |      1 |
| cp1250   | Windows Central European    | cp1250_general_ci   |      1 |
| gbk      | GBK Simplified Chinese      | gbk_chinese_ci      |      2 |
| latin5   | ISO 8859-9 Turkish          | latin5_turkish_ci   |      1 |
| armscii8 | ARMSCII-8 Armenian          | armscii8_general_ci |      1 |
| utf8     | UTF-8 Unicode               | utf8_general_ci     |      3 |
| ucs2     | UCS-2 Unicode               | ucs2_general_ci     |      2 |
| cp866    | DOS Russian                 | cp866_general_ci    |      1 |
| keybcs2  | DOS Kamenicky Czech-Slovak  | keybcs2_general_ci  |      1 |
| macce    | Mac Central European        | macce_general_ci    |      1 |
| macroman | Mac West European           | macroman_general_ci |      1 |
| cp852    | DOS Central European        | cp852_general_ci    |      1 |
| latin7   | ISO 8859-13 Baltic          | latin7_general_ci   |      1 |
| utf8mb4  | UTF-8 Unicode               | utf8mb4_general_ci  |      4 |
| cp1251   | Windows Cyrillic            | cp1251_general_ci   |      1 |
| utf16    | UTF-16 Unicode              | utf16_general_ci    |      4 |
| utf16le  | UTF-16LE Unicode            | utf16le_general_ci  |      4 |
| cp1256   | Windows Arabic              | cp1256_general_ci   |      1 |
| cp1257   | Windows Baltic              | cp1257_general_ci   |      1 |
| utf32    | UTF-32 Unicode              | utf32_general_ci    |      4 |
| binary   | Binary pseudo charset       | binary              |      1 |
| geostd8  | GEOSTD8 Georgian            | geostd8_general_ci  |      1 |
| cp932    | SJIS for Windows Japanese   | cp932_japanese_ci   |      2 |
| eucjpms  | UJIS for Windows Japanese   | eucjpms_japanese_ci |      3 |
+----------+-----------------------------+---------------------+--------+

https://mariadb.org/

Creating an instance

docker run -it --name mysql -p 3306:3306 -v /var/lib/mysql:/var/lib/mysql -e MYSQL_DATABASE=wordpressdb -e MYSQL_USER=wordpressuser -e MYSQL_PASSWORD=hguyFt6S95dgfR4ryb -e MYSQL_ROOT_PASSWORD=hguyFtgfR4r9R4r76 yobasystems/alpine-mariadb

It will create a new db, and set mysql root password (default is RaNd0MpA$$W0Rd generated by pwgen) unless the data already exists.

Configuration without a cnf file

Many configuration options can be passed as flags to mysqld. This will give you the flexibility to customise 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:

docker run --name some-mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -d yobasystems/alpine-mariadb --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

command:

  • --character-set-server=utf8
  • --collation-server=utf8_bin
  • --explicit-defaults-for-timestamp=1

Configuration file location

The configuration file is located;

  • /etc/my.cnf
  • /etc/my.cnf.d/mariadb-server.cnf

Initialising a fresh instance

When a container is started for the first time, a new database with the specified name will be created and initialised with the provided configuration variables. Furthermore, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical order. You can easily populate your mariadb services by mounting a SQL dump into that directory and provide custom images with contributed data. SQL files will be imported by default to the database specified by the MYSQL_DATABASE variable.

Docker Compose example:

(Please pass your own credentials or let them be generated automatically, don't use these ones for production!!)
mysql:
  image: yobasystems/alpine-mariadb
  environment:
    MYSQL_ROOT_PASSWORD: hguyFtgfR4r9R4r76
    MYSQL_DATABASE: wordpressdb
    MYSQL_USER: wordpressuser
    MYSQL_PASSWORD: hguyFt6S95dgfR4ryb
  expose:
    - "3306"
  volumes:
    - /data/example/mysql:/var/lib/mysql
  restart: always

πŸ” Image contents & Vulnerability analysis

PACKAGE NAME PACKAGE VERSION VULNERABILITIES

πŸ“š Source Repositories

🐳 Container Registries

πŸ”— Links

πŸ’° Donation

BMAC

BITCOIN

ETHEREUM

alpine-mariadb's People

Contributors

dominictayloruk avatar stevoh6 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alpine-mariadb's Issues

NFS volume fail starts

Hello everybody, please help me with this installation of this image with this configuration:
docker-compose.yml

version: "3"
services:
  mysql:
      image: yobasystems/alpine-mariadb
      volumes:
        - "nfsdb:/var/lib/mysql/"
      networks:
        - backend
      environment:
        MYSQL_ROOT_PASSWORD: somewordpress
        MYSQL_DATABASE: wordpressdb
        MYSQL_USER: wordpress
        MYSQL_PASSWORD: mariadb_root
volumes:
  nfsdb:
    driver: local
    driver_opts:
      type: nfs
      o: addr=storage01,hard,nolock,rw
      device: ":/shared/disk02"
networks:
  backend:
    driver: bridge

On NFS server I have:

/etc/exports
/shared/disk02           192.168.122.0/24(rw,async,no_wdelay,crossmnt,no_root_squash,insecure_locks,sec=sys,no_subtree_check)

NFS permissions server:

drwxr-sr-x  2 _apt   systemd-journal  4096 Oct 22 10:55 disk02

my initial permissions was: chown -R nobody:nogroup disk02 && chmod 777 disk02
When I try to run with docker-compose I have this error log and the data base don't start:
Log error:

[i] mysqld not found, creating....
[i] MySQL data directory not found, creating initial DBs
2019-10-22 14:55:34 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 0 pages than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2019-10-22 14:55:34 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-10-22 14:55:35 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-10-22 14:55:35 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-10-22 14:55:35 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2019-10-22 14:55:35 0 [ERROR] Aborting

I'm using debian 10 buster as NFS server and my PC is ubuntu 18.04 with docker version 8.09.5

Thanks for advance.

Version mismatch

When I run image it seems to be 10.2.15

# docker run yobasystems/alpine-mariadb -it
Unable to find image 'yobasystems/alpine-mariadb:latest' locally
latest: Pulling from yobasystems/alpine-mariadb
b1b0192ffc18: Already exists 
ce1a03b0d681: Pull complete 
a0f38cabfc11: Pull complete 
8f11901a56df: Pull complete 
Digest: sha256:8226fbe7d70fe4b1d8023b0eac09d84ebbacf72be8fc153e1835c6fd0206280a
Status: Downloaded newer image for yobasystems/alpine-mariadb:latest
[i] mysqld not found, creating....
[i] MySQL data directory not found, creating initial DBs
2018-09-23  7:11:07 140222561221352 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1146: Table 'mysql.gtid_slave_pos' doesn't exist
[i] MySQL root Password: meiNgohl6ahphaed
2018-09-23  7:11:09 140014111140744 [Note] /usr/bin/mysqld (mysqld 10.2.15-MariaDB-log) starting as process 66 ...
2018-09-23  7:11:09 140014111140744 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-09-23  7:11:09 140014111140744 [Note] InnoDB: Uses event mutexes

Initializing a fresh instance

Official image for mariadb has this very handy feature about initializing database from mounted volume. Can you please add it to this image?

https://hub.docker.com/_/mariadb/

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 and .sql.gz that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical order. You can easily populate your mariadb services by mounting a SQL dump into that directory and provide custom images with contributed data. SQL files will be imported by default to the database specified by the MYSQL_DATABASE variable.

mariadb failing to create a new user

using the docker-compose example, when doing an initial docker-compose up, the run.sh fails to create the database and user (root is created ok with a random password). I also can't seem to connect to mariadb with the root password (i'm using expose 3306) from the host.

on the initial run, i do see in the script an error:

mariadb_1    | 2017-06-13 16:22:23 140096404945736 [Note] Plugin 'FEEDBACK' is disabled.
mariadb_1    | ERROR: 1133  Can't find any matching row in the user table
mariadb_1    | 2017-06-13 16:22:23 140096404945736 [ERROR] Aborting
mariadb_1    | 

Start fails with "Too many arguments (first extra is 'mysqld')"

When command line options are used, the container fails to start:

docker run -e MYSQL_ROOT_PASSWORD=my-secret-pw yobasystems/alpine-mariadb --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
...
/usr/bin/mysqld: Too many arguments (first extra is 'mysqld').
2018-12-02  9:50:34 140186701331336 [ERROR] Aborting

(see mariadb.log for the complete log)

Define User on Host

I've been trying to change all of my containers to use a specific user on the host system, using the "user" config option in compose if the container doesn't support UID by default. This container seems to fail to start with that even if the ownership of directories are correct. This line seems most relevant but I'll link the full log "/usr/bin/mysqld: One can only use the --user switch if running as root" https://pastebin.com/53WYt41t Is this something that won't work with this container or am I doing just missing something?

Connecting to alpine-mariadb from another Docker container - arm32v7

I want to access data of an alpine-mariadb from a Python script that is in another Docker container on a Raspberry Pi 2 (armhf/arm32v7).

After executing the command:
docker run -it --name mariadb -p 3306:3306 -v /var/lib/mysql:/var/lib/mysql -e MYSQL_DATABASE=mydb -e MYSQL_USER=root -e MYSQL_PASSWORD=password -e MYSQL_ROOT_PASSWORD=password yobasystems/alpine-mariadb:arm32v7
the following output arises:

[i] mysqld not found, creating....
[i] MySQL data directory not found, creating initial DBs
43516-01-16 16:49:34 0 [ERROR] This MySQL server doesn't support dates later than 2038
[i] Creating database: mydb
[i] with character set: 'utf8' and collation: 'utf8_general_ci'
[i] Creating user: root with password password
323662-03-12  5:39:11 0 [ERROR] This MySQL server doesn't support dates later than 2038
/scripts/run.sh: ignoring or entrypoint initdb empty /docker-entrypoint-initdb.d/*
MySQL init process done. Ready for start up.
exec /usr/bin/mysqld --user=mysql --console --skip-name-resolve --skip-networking=0

Unfortunately, I can't get a connection from Python to the database. Is Docker Compose needed for this?

Docker-Compose Mapped volumes in host uid=systemd-timesync / gp=input. Backups with root pwd fails.

Hi, by starting up the MAriaDB with a docker-compose, and mapping a folder on the docker host where the db is to be stored, it runs, but the host folders ownership changes, to systemd-timesync / input.

the result of this is that I cannot backup the db with mysqldump command with root, as it does not have rights to the folder where the DB is now mounted.

Others reports the same problem on other docker images, with several fixes. This guy proposes to do a chmod after creation of the volume, or adding another user for the docker mariadb client.

Am I doing something wrong, or is this something you could add?

Thank you for a great image !

Versioning and Tags

This looks like a widely accepted image for mariadb on alpine linux. Unfortunately it lacks some versioning tags. It is not recommended to use :latest tag as it might fail when a newer version is released. Instead you should use a specific version.

But this image has only 10.5.9, 10.5.8 etc... When I'm using 10.5.9 now and there is a security issue in 10.5.9 I will not get an update to 10.5.10 until I change the used tag. My suggestion is to tag every image 3 times: :10.5.9 would get :10.5 and :10 to have :10 as the latest version of major release 10 and :10.5 as the latest version of minor release 10.5.

I'm doing something similar for my images and I'm happy to provide a PR if you like to have this feature too.

mysql_upgrade is missing

After upgrading the container, I get the error: 2019-02-11 18:19:57 0 [ERROR] Incorrect definition of table mysql.event: expected column 'sql_mode' at position 14 to have type set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH','EMPTY_STRING_IS_NULL','SIMULTANEOUS_ASSIGNMENT'), found type set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALU
and
2019-02-11 18:26:02 11 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade

But the container is missing the mysql_upgrade tool, I have tried to run mysqlcheck -u root -p'pw' --check-upgrade --auto-repair --all-databases but the problem persists.

Not passing parameters to mysqld

Using the official mariadb imagesIt is useful to pass some parameters to mysqld as described:

https://docs.docker.com/samples/library/mariadb/ in the section titled
"Configuration without a cnf file"

This can be used from a docker-compose-file like so:

command:
  - --character-set-server=utf8
  - --collation-server=utf8_bin
  - --explicit-defaults-for-timestamp=1

So I assume you just need: exec /usr/bin/mysqld --user=mysql --console $@

Docker Secrets

There is no support for 'Docker Secrets' in this image. The setup for Docker Secrets may be different between Docker Swarm and Docker Compose. However, the end result is the same. A plain text file will end up inside the container at '/run/secrets/' where each file will contain 1 secret (account name, password, etc.). The contents of this plain text file is then available to the entrypoint of the container.

The current build of this container uses these example environment variables:

    MYSQL_ROOT_PASSWORD: hguyFtgfR4r9R4r76
    MYSQL_DATABASE: wordpressdb
    MYSQL_USER: wordpressuser
    MYSQL_PASSWORD: hguyFt6S95dgfR4ryb
    MYSQL_CHARSET: utf8mb4
    MYSQL_COLLATION: utf8mb4_general_ci

The code that handles the environment variables appears to be in 'run.sh':

    if [ "$MYSQL_ROOT_PASSWORD" = "" ]; then
        MYSQL_ROOT_PASSWORD=`pwgen 16 1`
        echo "[i] MySQL root Password: $MYSQL_ROOT_PASSWORD"
    fi

    MYSQL_DATABASE=${MYSQL_DATABASE:-""}
    MYSQL_USER=${MYSQL_USER:-""}
    MYSQL_PASSWORD=${MYSQL_PASSWORD:-""}

The normal construct for using Docker Secrets is to use the same environment variable name(s), but with '_FILE' appended, thereby allowing the use of both the original environment variable or the path that contains the 'secret' value. The filename used for the secret is made up entirely by the user, but is usually something meaningful. Example:

    MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_pass
    MYSQL_DATABASE_FILE: /run/secrets/db_name
    MYSQL_USER_FILE: /run/secrets/db_admin_name
    MYSQL_PASSWORD_FILE: /run/secrets/db_admin_pass
    MYSQL_CHARSET: /run/secrets/db_charset
    MYSQL_COLLATION: /run/secrets/db_collation

Would it be possible to change this code to use docker secrets (i.e. parse the specified file in /run/secrets) for the information for these variables?

Proposed Example 'docker-compose.yml':

  services:
    mariadb:
      image: yobasystems/alpine-mariadb
      environment:
        MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_pass
        MYSQL_DATABASE_FILE: /run/secrets/db_name
        MYSQL_USER_FILE: /run/secrets/db_admin_name
        MYSQL_PASSWORD_FILE: /run/secrets/db_admin_pass
        MYSQL_CHARSET_FILE: /run/secrets/db_charset
        MYSQL_COLLATION_FILE: /run/secrets/db_collation

      secrets:
        - db_root_pass
        - db_name
        - db_admin_name
        - db_admin_pass
        - db_charset
        - db_collation
      expose:
        - "3306"
      volumes:
        - /data/example/mysql:/var/lib/mysql
      restart: always

  secrets:
    db_root_pass:
      file: ./private/db_root_pass.txt
    db_name:
      file: ./private/db_name.txt
    db_admin_name:
      file: ./private/db_admin_name.txt
    db_admin_pass:
      file: ./private/db_admin_pass.txt
    db_charset:
      file: ./private/db_charset.txt
    db_collation:
      file: ./private/db_collation.txt

Proposed Example 'run.sh' Code Change:

if [ "$MYSQL_ROOT_PASSWORD_FILE" = "" ]; then
    if [ "$MYSQL_ROOT_PASSWORD" = "" ]; then
        MYSQL_ROOT_PASSWORD=`pwgen 16 1`
        echo "[i] MySQL root Password: $MYSQL_ROOT_PASSWORD"
    fi
else
    MYSQL_ROOT_PASSWORD=`cat $MYSQL_ROOT_PASSWORD_FILE`
    echo "[i] MySQL Root Password: $MYSQL_ROOT_PASSWORD"
fi

if [ "$MYSQL_DATABASE_FILE" = "" ]; then
    MYSQL_DATABASE=${MYSQL_DATABASE:-""}
else
    MYSQL_DATABASE=`cat $MYSQL_DATABASE_FILE`
    echo "[i] MySQL Database Name: $MYSQL_DATABASE"
fi

if [ "$MYSQL_USER_FILE" = "" ]; then
    MYSQL_USER=${MYSQL_USER:-""}
else
    MYSQL_USER=`cat $MYSQL_USER_FILE`
    echo "[i] MySQL User Name: $MYSQL_USER"
fi

if [ "$MYSQL_PASSWORD_FILE" = "" ]; then
    MYSQL_PASSWORD=${MYSQL_PASSWORD:-""}
else
    MYSQL_PASSWORD=`cat $MYSQL_PASSWORD_FILE`
    echo "[i] MySQL User Password: $MYSQL_PASSWORD"
fi

if [ "$MYSQL_CHARSET_FILE" = "" ]; then
    MYSQL_CHARSET=${MYSQL_CHARSET:-""}
else
    MYSQL_CHARSET=`cat $MYSQL_CHARSET_FILE`
    echo "[i] MySQL User Password: $MYSQL_CHARSET"
fi

if [ "$MYSQL_COLLATION_FILE" = "" ]; then
    MYSQL_COLLATION=${MYSQL_COLLATION:-""}
else
    MYSQL_COLLATION=`cat $MYSQL_COLLATION_FILE`
    echo "[i] MySQL User Password: $MYSQL_COLLATION"
fi

Assuming that each 'db_*.txt' file referenced above contained the original example values, then this would allow users to provide both of these with the same result:

    MYSQL_ROOT_PASSWORD: hguyFtgfR4r9R4r76
    MYSQL_DATABASE: wordpressdb
    MYSQL_USER: wordpressuser
    MYSQL_PASSWORD: hguyFt6S95dgfR4ryb
    MYSQL_CHARSET: utf8mb4
    MYSQL_COLLATION: utf8mb4_general_ci

and

    MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_pass
    MYSQL_DATABASE_FILE: /run/secrets/db_name
    MYSQL_USER_FILE: /run/secrets/db_admin_name
    MYSQL_PASSWORD_FILE: /run/secrets/db_admin_pass
    MYSQL_CHARSET_FILE: /run/secrets/db_charset
    MYSQL_COLLATION_FILE: /run/secrets/db_collation

Also, in the event that a user provides both secret and non-secret values for the same thing (i.e. MYSQL_USER and MYSQL_USER_FILE), the secret value will override the non-secret value in this proposed code change.

Thank you for your attention.

EDIT: Typos (x3).

Stable versioning

Hi,

I think it may be a good idea to keep tags like on the original MariaDB image eg. 13.2, 13.2.1, latest. What do you think?

Econnrefused error and

getting the following errors

[4/25/2021] [11:48:04 AM] [Global ] β€Ί βœ– error connect ECONNREFUSED 172.22.0.2:3306

and

[i] mysqld not found, creating....

[i] MySQL data directory not found, creating initial DBs

233980-03-27 11:18:17 0 [ERROR] This MySQL server doesn't support dates later than 2038

Creating database: npm

[i] with character set: 'utf8' and collation: 'utf8_general_ci'

[i] Creating user: npm with password xxxxxxx

275081-09-13 20:01:08 0 [ERROR] This MySQL server doesn't support dates later than 2038

/scripts/run.sh: ignoring or entrypoint initdb empty /docker-entrypoint-initdb.d/*

MySQL init process done. Ready for start up.

exec /usr/bin/mysqld --user=mysql --console --skip-name-resolve --skip-networking=0

515981-12-18 5:22:21 0 [ERROR] This MySQL server doesn't support dates later than 2038

[i] mysqld already present, skipping creation

[i] MySQL data directory not found, creating initial DBs

Unknown/unsupported storage engine: InnoDB

Getting an error Unknown/unsupported storage engine: InnoDB. This is my compose file snippet

mysql:
    container_name: ${APP_NAME}-mysql
    image: yobasystems/alpine-mariadb
    ports:
    - 8806:3306/tcp
    volumes:
    - './docker/data/mysql:/var/lib/mysql'
    environment:
    - MYSQL_ROOT_PASSWORD=${APP_NAME}
    - MYSQL_DATABASE=${APP_NAME}
    - MYSQL_USER=${APP_NAME}
    - MYSQL_PASSWORD=${APP_NAME}

After update to new image with MariaDB 10.3.12 no connection possible

Because the logs, I overlooked the bigger problem, container is not reachable from the outside.
I also try to create a new database but the container refuse all connections, so I see in the logs:

Version: '10.3.12-MariaDB' socket: '/run/mysqld/mysqld.sock' port: 0 MariaDB Server

The port is wrong, maybe a wrong default configuration?

Doesn't start since update

Getting this while starting.
/usr/bin/mysqld: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 "No such file or directory")

This is how I test.

services:
  test-db:
    container_name: test-db
    image: yobasystems/alpine-mariadb:latest
    environment:
      MYSQL_ROOT_PASSWORD: secret
    restart: always

Start fails after 9 november update

arm32v7 image with mounted database

log is saying:
/scripts/run.sh: wait: line 89: Illegal number:
SQL init process failed.
[i] mysqld already present, skipping creation
[i] MySQL directory already present, skipping creation
/scripts/run.sh: wait: line 89: Illegal number:
SQL init process failed.
/scripts/run.sh: ignoring /docker-entrypoint-initdb.d/*

Inoperable on ZFS Hosts

It appears that this container is using a version of MariaDB that attempts to use fallocate(...) on all Linux systems - which will fail if the host FS doesn't support that (ZFS being a notable case).

Upstream issue tracker suggests this is resolved if you take a later MariaDB build: https://jira.mariadb.org/browse/MDEV-16015

Confirmed using an alternative 10.5.8 build works for my deployment.

[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

Error appears on two different machines when doing a fresh run. Looks like it fails to create the initial databases.

# From your Docker Hub page
docker run -it --rm --name mysql -p 3306:3306 -v /home/user/mysql:/var/lib/mysql -e MYSQL_DATABASE=wordpressdb -e MYSQL_USER=wordpressuser -e MYSQL_PASSWORD=hguyFt6S95dgfR4ryb -e MYSQL_ROOT_PASSWORD=hguyFtgfR4r9R4r76 yobasystems/alpine-mariadb
[i] mysqld not found, creating....
[i] MySQL data directory not found, creating initial DBs
[i] Creating database: wordpressdb
[i] Creating user: wordpressuser with password hguyFt6S95dgfR4ryb
2019-03-01  7:34:22 0 [Note] /usr/bin/mysqld (mysqld 10.3.13-MariaDB) starting as process 66 ...
2019-03-01  7:34:22 0 [Note] InnoDB: Using Linux native AIO
2019-03-01  7:34:22 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
2019-03-01  7:34:22 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-03-01  7:34:22 0 [Note] InnoDB: Uses event mutexes
2019-03-01  7:34:22 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-03-01  7:34:22 0 [Note] InnoDB: Number of pools: 1
2019-03-01  7:34:22 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-03-01  7:34:22 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-03-01  7:34:22 0 [Note] InnoDB: Completed initialization of buffer pool
2019-03-01  7:34:22 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-03-01  7:34:22 0 [Note] InnoDB: Setting file './ibdata1' size to 12 MB. Physically writing the file full; Please wait ...
2019-03-01  7:34:22 0 [Note] InnoDB: File './ibdata1' size is now 12 MB.
2019-03-01  7:34:22 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 50331648 bytes
2019-03-01  7:34:22 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 50331648 bytes
2019-03-01  7:34:22 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2019-03-01  7:34:22 0 [Note] InnoDB: New log files created, LSN=45786
2019-03-01  7:34:22 0 [Note] InnoDB: Doublewrite buffer not found: creating new
2019-03-01  7:34:22 0 [Note] InnoDB: Doublewrite buffer created
2019-03-01  7:34:22 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-03-01  7:34:22 0 [Note] InnoDB: Creating foreign key constraint system tables.
2019-03-01  7:34:22 0 [Note] InnoDB: Creating tablespace and datafile system tables.
2019-03-01  7:34:22 0 [Note] InnoDB: Creating sys_virtual system tables.
2019-03-01  7:34:22 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-03-01  7:34:22 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-03-01  7:34:22 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-03-01  7:34:22 0 [Note] InnoDB: Waiting for purge to start
2019-03-01  7:34:22 0 [Note] InnoDB: 10.3.13 started; log sequence number 0; transaction id 7
2019-03-01  7:34:22 0 [Note] Plugin 'FEEDBACK' is disabled.
ERROR: 1049  Unknown database 'mysql'
2019-03-01  7:34:22 0 [ERROR] Aborting

/scripts/run.sh: ignoring or entrypoint initdb empty /docker-entrypoint-initdb.d/*


MySQL init process done. Ready for start up.

exec /usr/bin/mysqld --user=mysql --console --skip-name-resolve --skip-networking=0
2019-03-01  7:34:24 0 [Note] /usr/bin/mysqld (mysqld 10.3.13-MariaDB) starting as process 1 ...
2019-03-01  7:34:24 0 [Note] InnoDB: Using Linux native AIO
2019-03-01  7:34:24 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-03-01  7:34:24 0 [Note] InnoDB: Uses event mutexes
2019-03-01  7:34:24 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-03-01  7:34:24 0 [Note] InnoDB: Number of pools: 1
2019-03-01  7:34:24 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-03-01  7:34:24 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-03-01  7:34:24 0 [Note] InnoDB: Completed initialization of buffer pool
2019-03-01  7:34:24 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-03-01  7:34:24 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-03-01  7:34:24 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-03-01  7:34:24 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-03-01  7:34:24 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-03-01  7:34:24 0 [Note] InnoDB: Waiting for purge to start
2019-03-01  7:34:24 0 [Note] InnoDB: 10.3.13 started; log sequence number 1603959; transaction id 9
2019-03-01  7:34:24 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-03-01  7:34:24 0 [Note] InnoDB: Buffer pool(s) load completed at 190301  7:34:24
2019-03-01  7:34:24 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-03-01  7:34:24 0 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
2019-03-01  7:34:24 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
2019-03-01  7:34:24 0 [Note] Server socket created on IP: '::'.
2019-03-01  7:34:24 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

No permissions for anyone@localhost

frebib@Ares /e/s/s/cacti> dsh cacti-db                                                                                     master!?
/ # echo 'SELECT 1+1;' | mysql -u root -p${MYSQL_ROOT_PASSWORD}
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
/ # echo $MYSQL_ROOT_PASSWORD
iND2vpSZsNeirlFgTonDzEbNcFaOzV3s
/ # echo 'SELECT 1+1;' | mysql -u $MYSQL_USER -p${MYSQL_PASSWORD}
ERROR 1045 (28000): Access denied for user 'cacti'@'localhost' (using password: YES)
/ # echo 'SELECT 1+1;' | mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p${MYSQL_PASSWORD}
ERROR 1045 (28000): Access denied for user 'cacti'@'localhost' (using password: YES)

I'm slightly confused by this because the init script adds permissions for both root and the other user. Any ideas as to why?

I'm starting the container with no volumes so the database gets initialised each time and using almost the same docker-compose config provided in the README

execution of sql script in /docker-entrypoint-initdb.d/* fails

In the run script you are executing all sql scripts whit the mysql command like this
*.sql) echo "$0: running $f"; mysql -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE < "$f";
but it seems the database isn't started yet, so mysql is not able to connect to the server.

I tried to start the daemon before executing mysql but I wasn't successful, so I just replaced the line with
*.sql) echo "$0: running $f"; /usr/bin/mysqld --user=mysql --bootstrap --skip-name-resolve < $f; echo ;;
This is working for me but I'm not a mariadb expert, so I don't know if this is a feasible solution.

No ability to auto-create database with a different charset/collation

First off, I love the container. Thank you.

Also, I'm relatively new to 'Issues' vs 'Enhancement Requests.' So If I'm doing this wrong, please let me know. This is an issue, but also an enhancement request.

My issue is that my use case requires an initial database to be auto-created that's 'utf8mb4' for the character set and the default 'utf8mb4_general_ci' for collation. When I run a container using the example provided:

--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

This creates a 'mysql' database that meets the requirements, but the additional auto-created database is still 'utf8' and 'utf8_general_ci'.

MariaDB [(none)]> SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation' FROM information_schema.SCHEMATA;
+--------------------+---------+--------------------+
| database           | charset | collation          |
+--------------------+---------+--------------------+
| information_schema | utf8    | utf8_general_ci    |
| mysql              | utf8mb4 | utf8mb4_unicode_ci |
| performance_schema | utf8    | utf8_general_ci    |
| my_database        | utf8    | utf8_general_ci    |
+--------------------+---------+--------------------+
4 rows in set (0.001 sec)

The code that auto-creates the additional database appears to be in 'run.sh':

	if [ "$MYSQL_DATABASE" != "" ]; then
	    echo "[i] Creating database: $MYSQL_DATABASE"
	    echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` CHARACTER SET utf8 COLLATE utf8_general_ci;" >> $tfile

	    if [ "$MYSQL_USER" != "" ]; then
		echo "[i] Creating user: $MYSQL_USER with password $MYSQL_PASSWORD"
		echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* to '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';" >> $tfile
	    fi
	fi

Would it be possible to change this code to allow the user to provide the character set and collation desired using two environment variables?

Proposed Example 'docker-compose.yml':

	mysql:
	  image: yobasystems/alpine-mariadb
	  environment:
		MYSQL_ROOT_PASSWORD: hguyFtgfR4r9R4r76
		MYSQL_DATABASE: wordpressdb
		MYSQL_USER: wordpressuser
		MYSQL_PASSWORD: hguyFt6S95dgfR4ryb
		MYSQL_CHARSET: utf8mb4
		MYSQL_COLLATION: utf8mb4_general_ci
	  expose:
		- "3306"
	  volumes:
		- /data/example/mysql:/var/lib/mysql
	  restart: always

Proposed Example 'run.sh' Code Change:

	if [ "$MYSQL_DATABASE" != "" ]; then
	    echo "[i] Creating database: $MYSQL_DATABASE"
		if [ "$MYSQL_CHARSET" != "" ] && [ "$MYSQL_COLLATION" != "" ]; then
			echo "[i] with character set [$MYSQL_CHARSET] and collation [$MYSQL_COLLATION]"
			echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` CHARACTER SET $MYSQL_CHARSET COLLATE $MYSQL_COLLATION;" >> $tfile
		else
			echo "[i] with character set: 'utf8' and collation: 'utf8_general_ci'"
			echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` CHARACTER SET utf8 COLLATE utf8_general_ci;" >> $tfile
		fi

	    if [ "$MYSQL_USER" != "" ]; then
		echo "[i] Creating user: $MYSQL_USER with password $MYSQL_PASSWORD"
		echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* to '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';" >> $tfile
	    fi
	fi

This would default to 'utf8' and 'utf8_general_ci' unless a user provided both values, but also allow a user to provide any of these:

MariaDB [(none)]> SHOW CHARACTER SET;
+----------+-----------------------------+---------------------+--------+
| Charset  | Description                 | Default collation   | Maxlen |
+----------+-----------------------------+---------------------+--------+
| big5     | Big5 Traditional Chinese    | big5_chinese_ci     |      2 |
| dec8     | DEC West European           | dec8_swedish_ci     |      1 |
| cp850    | DOS West European           | cp850_general_ci    |      1 |
| hp8      | HP West European            | hp8_english_ci      |      1 |
| koi8r    | KOI8-R Relcom Russian       | koi8r_general_ci    |      1 |
| latin1   | cp1252 West European        | latin1_swedish_ci   |      1 |
| latin2   | ISO 8859-2 Central European | latin2_general_ci   |      1 |
| swe7     | 7bit Swedish                | swe7_swedish_ci     |      1 |
| ascii    | US ASCII                    | ascii_general_ci    |      1 |
| ujis     | EUC-JP Japanese             | ujis_japanese_ci    |      3 |
| sjis     | Shift-JIS Japanese          | sjis_japanese_ci    |      2 |
| hebrew   | ISO 8859-8 Hebrew           | hebrew_general_ci   |      1 |
| tis620   | TIS620 Thai                 | tis620_thai_ci      |      1 |
| euckr    | EUC-KR Korean               | euckr_korean_ci     |      2 |
| koi8u    | KOI8-U Ukrainian            | koi8u_general_ci    |      1 |
| gb2312   | GB2312 Simplified Chinese   | gb2312_chinese_ci   |      2 |
| greek    | ISO 8859-7 Greek            | greek_general_ci    |      1 |
| cp1250   | Windows Central European    | cp1250_general_ci   |      1 |
| gbk      | GBK Simplified Chinese      | gbk_chinese_ci      |      2 |
| latin5   | ISO 8859-9 Turkish          | latin5_turkish_ci   |      1 |
| armscii8 | ARMSCII-8 Armenian          | armscii8_general_ci |      1 |
| utf8     | UTF-8 Unicode               | utf8_general_ci     |      3 |
| ucs2     | UCS-2 Unicode               | ucs2_general_ci     |      2 |
| cp866    | DOS Russian                 | cp866_general_ci    |      1 |
| keybcs2  | DOS Kamenicky Czech-Slovak  | keybcs2_general_ci  |      1 |
| macce    | Mac Central European        | macce_general_ci    |      1 |
| macroman | Mac West European           | macroman_general_ci |      1 |
| cp852    | DOS Central European        | cp852_general_ci    |      1 |
| latin7   | ISO 8859-13 Baltic          | latin7_general_ci   |      1 |
| utf8mb4  | UTF-8 Unicode               | utf8mb4_general_ci  |      4 |
| cp1251   | Windows Cyrillic            | cp1251_general_ci   |      1 |
| utf16    | UTF-16 Unicode              | utf16_general_ci    |      4 |
| utf16le  | UTF-16LE Unicode            | utf16le_general_ci  |      4 |
| cp1256   | Windows Arabic              | cp1256_general_ci   |      1 |
| cp1257   | Windows Baltic              | cp1257_general_ci   |      1 |
| utf32    | UTF-32 Unicode              | utf32_general_ci    |      4 |
| binary   | Binary pseudo charset       | binary              |      1 |
| geostd8  | GEOSTD8 Georgian            | geostd8_general_ci  |      1 |
| cp932    | SJIS for Windows Japanese   | cp932_japanese_ci   |      2 |
| eucjpms  | UJIS for Windows Japanese   | eucjpms_japanese_ci |      3 |
+----------+-----------------------------+---------------------+--------+
40 rows in set (0.000 sec)

Also, for the use case that a user simply flubs up the values they provide this way, a warning could be placed in the README.md that invalid values could cause the container to become unstable or not start at all.

I can make the change myself using the Dockerfile and 'run.sh' you've provided, but I thought I'd ask here first.

Thank you for your attention.

EDIT: Typos

Persistence Not working

I am trying to use this with a persistence file. so when I add the Volumes tag and a file allocation it errors out and shuts down. Any ideas why this would be happening?

I do not get this error when not specifying a volume.

Docker compose file:

mysql:
image: 'yobasystems/alpine-mariadb:latest'
environment:
MYSQL_ROOT_PASSWORD: 'npm'
MYSQL_DATABASE: 'npm'
MYSQL_USER: 'npm'
MYSQL_PASSWORD: 'npm'
volumes:
- ./data/mysql:/var/lib/mysql

Error log:

[i] mysqld not found, creating....,
[i] MySQL data directory not found, creating initial DBs,
2021-03-31 19:06:33 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 0 pages than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!,
2021-03-31 19:06:33 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error,
2021-03-31 19:06:35 0 [ERROR] Plugin 'InnoDB' init function returned error.,
2021-03-31 19:06:35 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.,
2021-03-31 19:06:35 0 [ERROR] Unknown/unsupported storage engine: InnoDB,
2021-03-31 19:06:35 0 [ERROR] Aborting,
 Creating database: npm,
[i] with character set: 'utf8' and collation: 'utf8_general_ci',
[i] Creating user: npm with password npm,
2021-03-31 19:06:35 0 [Note] /usr/bin/mysqld (mysqld 10.4.15-MariaDB) starting as process 56 ...,
2021-03-31 19:06:35 0 [Note] InnoDB: Using Linux native AIO,
2021-03-31 19:06:35 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins,
2021-03-31 19:06:35 0 [Note] InnoDB: Uses event mutexes,
2021-03-31 19:06:35 0 [Note] InnoDB: Compressed tables use zlib 1.2.11,
2021-03-31 19:06:35 0 [Note] InnoDB: Number of pools: 1,
2021-03-31 19:06:35 0 [Note] InnoDB: Using generic crc32 instructions,
2021-03-31 19:06:35 0 [Note] mysqld: O_TMPFILE is not supported on /var/tmp (disabling future attempts),
2021-03-31 19:06:35 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M,
2021-03-31 19:06:36 0 [Note] InnoDB: Completed initialization of buffer pool,
2021-03-31 19:06:36 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().,
2021-03-31 19:06:36 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 0 pages than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!,
2021-03-31 19:06:36 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error,
2021-03-31 19:06:36 0 [Note] InnoDB: Starting shutdown...,
2021-03-31 19:06:37 0 [ERROR] Plugin 'InnoDB' init function returned error.,
2021-03-31 19:06:37 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.,
2021-03-31 19:06:37 0 [Note] Plugin 'FEEDBACK' is disabled.,
2021-03-31 19:06:37 0 [ERROR] Unknown/unsupported storage engine: InnoDB,
2021-03-31 19:06:37 0 [ERROR] Aborting,
/scripts/run.sh: ignoring or entrypoint initdb empty /docker-entrypoint-initdb.d/*,
,
,
MySQL init process done. Ready for start up.,
,
exec /usr/bin/mysqld --user=mysql --console --skip-name-resolve --skip-networking=0,
2021-03-31 19:06:37 0 [Note] /usr/bin/mysqld (mysqld 10.4.15-MariaDB) starting as process 1 ...,
2021-03-31 19:06:37 0 [Note] InnoDB: Using Linux native AIO,
2021-03-31 19:06:37 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins,
2021-03-31 19:06:37 0 [Note] InnoDB: Uses event mutexes,
2021-03-31 19:06:37 0 [Note] InnoDB: Compressed tables use zlib 1.2.11,
2021-03-31 19:06:37 0 [Note] InnoDB: Number of pools: 1,
2021-03-31 19:06:37 0 [Note] InnoDB: Using generic crc32 instructions,
2021-03-31 19:06:37 0 [Note] mysqld: O_TMPFILE is not supported on /var/tmp (disabling future attempts),
2021-03-31 19:06:38 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M,
2021-03-31 19:06:38 0 [Note] InnoDB: Completed initialization of buffer pool,
2021-03-31 19:06:38 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().,
2021-03-31 19:06:38 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 0 pages than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!,
2021-03-31 19:06:38 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error,
2021-03-31 19:06:38 0 [Note] InnoDB: Starting shutdown...,
2021-03-31 19:06:39 0 [ERROR] Plugin 'InnoDB' init function returned error.,
2021-03-31 19:06:39 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.,
2021-03-31 19:06:39 0 [Note] Plugin 'FEEDBACK' is disabled.,
2021-03-31 19:06:39 0 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded,
2021-03-31 19:06:39 0 [ERROR] Unknown/unsupported storage engine: InnoDB,
2021-03-31 19:06:39 0 [ERROR] Aborting,

views are not granted to default user

When creating a DB using init scripts, the TABLEs can be accessed by the user created with environment variables. However, the VIEWs are not accessible.

Can someone reproduce this?

Thanks!

Table '/tmp/#sql_1_0.MAI' is read only

When I ran the image In CentOS 7.3 , the error happened.

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> desc user;
ERROR 1036 (HY000): Table '/tmp/#sql_1_0.MAI' is read only

docker-entrypoint-initdb.d does not select main database

Hello!
When inserting data via the entrypoint, there is no database selected by default, while I define my env var for MYSQL_DATABASE.

Affected line: https://github.com/yobasystems/alpine-mariadb/blob/master/alpine-mariadb-armhf/files/run.sh#L70

I am not sure where the official images does that differently, since this is only echoed there:
https://github.com/docker-library/mariadb/blob/master/docker-entrypoint.sh#L178

Log

sicon_db   | /scripts/run.sh: running /docker-entrypoint-initdb.d/c-db_initialized.sql
sicon_db   | 2019-05-07  9:44:39 0 [Note] /usr/bin/mysqld (mysqld 10.3.13-MariaDB) starting as process 164 ... 
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Using Linux native AIO 
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Uses event mutexes
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Number of pools: 1
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Using SSE2 crc32 instructions
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Completed initialization of buffer pool 
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: 128 out of 128 rollback segments are active. 
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Creating shared tablespace for temporary tables
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Waiting for purge to start
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: 10.3.13 started; log sequence number 1630842; transaction id 21 
sicon_db   | 2019-05-07  9:44:39 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
sicon_db   | 2019-05-07  9:44:40 0 [Note] InnoDB: Buffer pool(s) load completed at 190507  9:44:40 
sicon_db   | 2019-05-07  9:44:40 0 [Note] Plugin 'FEEDBACK' is disabled.
sicon_db   | ERROR: 1046  No database selected 
sicon_db   | 2019-05-07  9:44:40 0 [ERROR] Aborting
sicon_db   |

Workaround - add a USE statement for my own entrypoint files.

How to set Innodb_force_recovery?

Hi there,
It seems my container didn't stop gracefully, which has resulted in the following error and restart loop:

[ERROR] InnoDB: Page [page id: space=0, page number=2] log sequence number 5160395 is in the future! Current system log sequence number 3981222.
[ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to https://mariadb.com/kb/en/library/innodb-recovery-modes/ for information about forcing recovery.

The mariadb knowledge base suggests setting innodb_force_recovery to 1, 2, 3 or 4 then starting MariaDB to attempt automatic repairs. How would I go about setting this for the docker container?

How to correctly use the tag ":v0.0.0"

By checking the documentation

Tags
:latest, :amd64 latest branch based on amd64
:master master branch usually inline with latest
:v0.0.0 version number related to mariadb version
:armhf, :arm32v7 Armv7 based on latest tag but arm architecture

I am trying to specify the tag ":vX.X.X" as described in the documentation to build the correct image for the desired mariadb version.

For example I am using in the Dockerfile:

FROM yobasystems/alpine-mariadb:v10.2.15
...etc...

However it fails.

The only working tags are the ones described here

Am I doing something wrong ?

Timezone ?

Hi,

impossible to change TZ on docker-compose using environnement variable:

environment:
  MYSQL_ROOT_PASSWORD: docker
  MYSQL_DATABASE: docker
  MYSQL_USER: docker
  MYSQL_PASSWORD: docker
  **TZ: "Europe/Paris"**

How is it possible to do this action ?

Fresh run creates too many users

mariadb:
  container_name: mariadb
  restart: unless-stopped
  image: yobasystems/alpine-mariadb
  volumes:
    - ./mariadb:/var/lib/mysql
  environment:
    MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
  networks:
    - proxy
  labels:
    - "traefik.enable=false"

alpine-mariadb with python on Raspberry Pi 2

Currently, I am in the process of implementing two Docker containers on the Raspberry Pi 2 - one for a Python and one for a mariadb database. The Python script is supposed to retrieve data from the database.

My .yml file to build the docker containers on Windows x64 :

    version: "3.9"
    services:
      app:
        build: ./app
        links:
          - db
        restart: on-failure
        
      db:
        image: yobasystems/alpine:3.13.5-armhf
        ports:
          - "3306:3306"
        environment:
          MYSQL_ROOT_PASSWORD: password
          MYSQL_DATABASE: mydb
        volumes:
          - ./db:/docker-entrypoint-initdb.d/:ro

Essential part of Python script:

    import mysql.connector
    
    mydb = mysql.connector.connect(
      host="db",
      user="root",
      password="password",
      database="mydb"
    )

I execute the commands on Windows x64:

    docker-compose up
    docker save -o mydb.tar mariadb_db_1
    docker save -o mypython.tar python_app_2

Then on the Raspberry Pi 2, I execute the commands:

    docker load -i mydb.tar
    docker load -i mypython.tar

    docker run -i -t mariadb_db_1
    docker run -i -t python_app_2

When I run mariadb_db_1, I get thrown right into the sh-shell (I don't know if database is running).
Then when I run python_app_2 from another shell, I get the following error from the mysql.connector.connect method: Can't connect to MySQL server on '%-.100s:%u' (%s)'

What could be the reason that it does not work under the Raspberry Pi 2? And why do I get thrown into the sh-shell with the database?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.