MariaDB setup configuration

Database container launch

The container is started using the docker command with the appropriate settings:

docker run --name mariadb-10.11 --volume /opt/mariadb-10.11/dbdata:/var/lib/mysql --volume /opt/mariadb-10.11/config:/etc/mysql -e MARIADB_ROOT_PASSWORD="{STRONG_PASSWORD}" -p 3312:3306 -p 33120:33060 -d mariadb:10.11

Let's consider each of these parameters:

--name mariadb-10.11 - container name. Consists of the database type mariadb and version 10.11

--volume /opt/mariadb-10.11/dbdata:/var/lib/mysql - container volume. You can read more about this on the corresponding docker manual page. But, at the moment, it is enough for us to know that the volume is used to save our data if the container is restarted or rebuilt. /opt/mariadb-10.11/dbdata - the folder in the external system where our data will be stored. /var/lib/mysql - the folder inside the container, which we want to save.

--volume /opt/mariadb-10.11/config:/etc/mysql - another container volumes for saving MySQL config files.

-e MARIADB_ROOT_PASSWORD="{STRONG_PASSWORD}" - initial password for root.

-p 3312:3306 - using this parameter, we set the port that will provide access to the container. 33102 - external port on which this container will be available.

-p 33120:33060 - port for X Protocol (mysqlx_port), supported by clients such as MySQL Shell, MySQL Connectors and MySQL Router, is calculated by multiplying the port used for classic MySQL protocol by 10. More details can be found at the link.

WARNING Before deploying a container to a specific port, you need to make sure that this port is free and not used by other containers. You can use docker ps -a to view all running and stopped containers.

3306 - the port on which the database is accessible inside the container. Thus, we forward requests from an external port to an open port inside the container.

-d - mean “detach”, we run container in background.

mariadb:10.11 - indicate the MariaDB image that exists on the docker hub with the corresponding version.

As a result of execution, we will see the following console picture:

Database Console Launch

Logging into the mariadb console of a docker container is done using the command:

docker exec -it mariadb-10.11 mysql -uroot -p{STRONG_PASSWORD}

As a result, we will observe the following picture in the console:

Setting up the database and access mode

The database is configured using sequential execution of SQL queries.

Let's create a database that will be used to data export:

CREATE DATABASE exportdb CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

These database settings are recommended in the corresponding Jira manual.

Create a user for the database that will use the login we created:


{STRONG_USER_PASSWORD} - the password that we will later use for export.

'exportuser'@'%' - at the moment, we only support working with users whose access is granted to any host (using the %).

flush privileges; - when we grant some privileges for a user, running the command flush privileges will reloads the grant tables in the mariadb database enabling the changes to take effect without reloading or restarting mysql service.

As a result, we will see the following picture in the console:

You can exit the console with exit.

Let's check if we have configured our database correctly and try to connect to it.