Overview

What is MariaDB

  • A branch of MySQL
    • MariaDB is a backward compatible, drop-in replacement for the MySQL Database Server
  • Open Source
    • The source code for MariaDB is publicly available from Launchpad
    • All code in MariaDB is open source
    • Open bugs database

Thus, just open-source kind of MySQL

Installation

MariaDB included into official Debian repository, hence its installation as usual is a string as root:

~# apt-get install mariadb-server mariadb-client

Installation success check is possible for ordinary user also:

mariadb --version
mariadb  Ver 15.1 Distrib 10.1.23-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Initial steps

In the most cases MariaDB treatments are identical with MySQL, thus there are several steps how to permit ordinary UNIX user to interact with SQL server on localhost.

It should to been noticed here that in accordion with Debian security policy by defauld only root is preliminary granted to resolve any DB administration issues. Thus all initial operations below should be executed as root, e.g. in separate terminal window after than you're switched user to root by su root.

Connect to MariaDB server

~# mariadb
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.1.23-MariaDB-9+deb9u1 Debian 9.0

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>   

The last string MariaDB [(none)]> welcomed you to input any command by typing and I might suggest to type help and overview its response.

Test DB creation

But our aim is to compose environment that allows an ordinary user to play with relational algebra equations in MariaDB. First of all we're need to create a dumb DB. Check up the existing ones:

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

These tables serve managerial role and you should aware to modify them. Lets create a particular DB as illustration of DB creation and for our educational and test purposes.

MariaDB [(none)]> create database fujitsu_db;
Query OK, 1 row affected (0.02 sec)

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

Dumb DB user creation

Now, when an educational DB successfully created we restricted by security policy organize interaction with it from non-administrative user. It's a trivial secure trick which effectively resolve a huge amount of secure problem. The general concept implies user's access control: each user has a definitely limited access to some particular data, and only root has an unlimited access to all available data.

MariaDB [(none)]> CREATE USER 'alioth'@'localhost' IDENTIFIED BY 'mypass';
Query OK, 0 rows affected (0.62 sec)

Test user priviledges granting

After when we're created a test DB and an dumb user it's time to tie these objects together.

MariaDB [(none)]> GRANT ALL ON fujitsu_db.* TO 'alioth'@'localhost';
Query OK, 0 rows affected (0.09 sec)

Emacs meets MariaDB

Interactive mode

Now, when we are freely capable to connect MariaDB client with server it's very moment to embed all this features into Emacs IDE.

Firstly it is worth to be noticed a Emacs' standard approach to SQL: M-x sql-mysql after than you're add SQL support in your init.el and re-launch Emacs. If description above can't eliminate your questions around MariaDB as a particular SQL host you might try to dismantle these knotty issues by reading:

As a result you'll should get this window for tame your MariaDB interactively:

Nice and dice

Figure 1: MariaDB client's interactive window



blog comments powered by Disqus

Published

02 July 2017

Categories

MariaDB Debian9 literate programming

Tags