Lesson 1: Getting Started

Getting started

Learning Objectives

Deployment

Supported Operating Systems

Operating SystemES10.6ES10.5ES10.4ES10.3
RHEL8 (x86_64 / ARM64)YesYesYesYes
RHEL7 (x86_64)YesYesYesYes
CentOS 7 (x86_64)YesYesYesYes
Ubuntu 20.04 (x86_64 / ARM64)YesYesYesYes
Ubuntu 18.04 (x86_64 / ARM64)YesYesYesYes
Debian 11 (x86_64 / ARM64)YesYesNoNo
Debian 10 (x86_64 / ARM64)YesYesYesYes
Debian 9 (x86_64 / ARM64)YesYesYesYes
SLES15 (x86_64 / ARM64)YesYesYesYes
SLES12 (x86_64)YesYesYesYes
Windows (x86_64)YesYesYesYes

Installation Methods and Packages

Installation Tools

Distribution Packages

Docker

The recommended way to install MariaDB is via MariaDB’s repository in conjunction with your distribution’s package manager.

Installing with Packages

Package Managers
Automatically places binaries, configuration and other files in correct locations

Configuration File
Add any system configuration items you require to the .cnf file

Maintained by MariaDB
Official package repositories are available on our website

Starting and Stopping the Server

systemctl [start|stop|restart|status] mariadb

Configure start and stop timeouts by creating a timeout.conf file

# vi /etc/systemd/system/mariadb.service.d/timeout.conf

[Service]
TimeoutStartSec=30min
TimeoutStopSec=30min

Reload the systemd daemon

# systemctl daemon-reload
# systemctl restart mariadb

Upgrading MariaDB

What to Consider

What to Prepare

Connectors and Utilities

Connectors

Various Libraries for connecting to MariaDB

*Wrapper for MariaDB C API, which uses the MariaDB Network Protocol
** Non-native (unsupported) Connectors to use with MariaDB

Client Connections

TCP/IP Connections available on All Platforms (skip_networking disables this)

Socket Files available on Unix Platforms (fastest choice)

Named Pipe (named_pipe) and Shared Memory (shared_memory) available on Windows

MariaDB Connections require few resources and are easy to open

Most use External Connection Pools (not needed usually)

Set Global Client Connection Limit (max_connections=n)

MariaDB Client - Command-line Tool

# mariadb --user=root -p
MariaDB [(none)]> SHOW DATABASES;
# mariadb -p -u user_name --execute "SHOW DATABASES"
# mariadb -e "CREATE DATABASE world"
# mariadb world < /path/to/world.sql

MariaDB-admin - Command-line Tool

# mariadb-admin processlist
# mariadb-admin kill 12345678
# mariadb-admin -u root -p create ragnar
# mariadb-admin extended-status
# mariadb-admin variables
# mariadb-admin ping
# mariadb-admin status
# mariadb-admin shutdown

Other Client Utilities

NameDescription
mariadb-backupOpen source tool provided by MariaDB for performing physical online backups of InnoDB and Aria tables. For InnoDB “hot online” backups are possible.
mariadb-binlogProcesses binary logs and relay logs. Used to read the binary log file, and is often used in restoring data to a particular point in time.
mariadb-checkChecks, repairs, analyzes and optimizes tables.
mariadb-dumpBackup tool that allows a logical dump of SQL data or schema from your database.
mariadb-secure-installationTool that enables you to improve the security of your MariaDB installation in various ways. You should run this after every installation of MariaDB server.
mariadb-upgradeTool that checks and updates your tables to the latest version.
mariadb-slapTool for load-testing MariaDB.
sysbenchAnother benchmarking tool that provides benchmarking capabilities for Linux. It supports testing CPU, memory, file I/O, mutex performance.
my_print_defaultsUseful in displaying the default settings that are given to the MariaDB daemon at startup, either manually or from the configuration file. Execute this from the command line followed by the –mysqld option.

Some Command Line Tools

NameDescription
mariadb-tzinfo-to-sqlUse to load time zones on systems that have a zoneinfo database to load the time zone tables into the mysql database.
mariadb-install-dbInitializes the MariaDB data directory and creates the system tables in the mysql database.
mariadb-showShows the structure of a MariaDB database (databases, tables, columns and indexes).
mariadb-dumpTool for examining the slow query log.
mariadb-dumpslowTool that enables you to improve the security of your MariaDB installation in various ways. This should be run after every installation of MariaDB server.
innochecksumprinting checksums for InnoDB files.
aria_chkchecks, repairs, optimizes, sorts and gets information about Aria tables.
aria_packTool for compressing Aria tables.
aria_read_logTool for displaying and applying log records from an Aria transaction log.

Graphical User Interface Tools

Windows

Mac and Linux

Configuration and Variables

Configuration File Locations

Linux

Windows

Server Defaults

Finding Defaults

# mariadbd --print-defaults

mariadbd would have been started with the following arguments:
- `--datadir=/data/mariadb`
- `--socket=/var/lib/mysql/mysql.sock`
- `--user=mysql`
- `--symbolic_links=0`
- `--local_infile=0`

Configuration File (server.cnf)

[server]

[mysqld]

[galera]

[embedded]

[mariadb]
datadir=/data/mariadb
socket=/var/lib/mysql/mysql.sock
user=mysql
symbolic_links=0
local_infile=0

[mariadb-10.6]

Setting the InnoDB Buffer Pool Size

The size of the buffer pool is the most important tunable for the InnoDB storage engine

The buffer pool size is determined by the innodb_buffer_pool_size

innodb_buffer_pool_size = 134217728

innodb_buffer_pool_chunk_size = 134217728

innodb_buffer_pool_dump_at_shutdown = ON

innodb_buffer_pool_load_at_startup = ON

innodb_buffer_pool_filename = ib_buffer_pool

Global and Status Variables

Global Variables

Global Status Variables

Session Variables

Global Variable Values are Defaults for New Sessions

SHOW GLOBAL VARIABLES LIKE '%character_set_client%';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| character_set_client | latin1 |
+--------------------+-------+

Session Variables are Values for Current Session

SHOW SESSION VARIABLES LIKE '%character_set_client%';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| character_set_client | greek |
+--------------------+-------+

Log Files

MariaDB Logs

Error Log

[mariadb]
log_error = /path/to/error_log_file_name
log_warnings = 1

Excerpt from server.cnf, my.cnf or my.ini configuration file

Set log_warnings to 2 for verbose mode

General Query Log

[mariadb]
general_log
general_log_file='/path/to/host.log'

Excerpt from server.cnf, my.cnf or my.ini configuration file

SQL Error Log

INSTALL PLUGIN sql_error_log SONAME 'sql_errlog';

Requires INSERT privilege for mysql.plugin table

Slow Query Log

[mariadb]
slow_query_log = 1
slow_query_log_file = /path/to/mariadb-slow.log
long_query_time = 2.0
# log_queries_not_using_indexes
log_slow_admin_statements=1
log_slow_disabled_statements='admin,call,slave,sp'

Managing Log Files

Regularly Rotate Logs File

FLUSH LOGS;
# mariadb-admin flush-logs

An alternative method from the command-line

Backups

Error Log

Linux logrotate Utility

Lesson Summary


For academic and non-commercial usage, licensed under CC BY-NC-SA 4.0 by MariaDB plc.