Mariadb is officially Database implementation of MySQL as many other Linux distributions. Today we will see HowTo Install and configure Mariadb Server on archlinux and see how we could simple Administrative task on same.

SetUP

For our setup we are using latest archlinux as of now Nov 2017.

[root@archlinux ~]# uname -rm
4.13.12-1-ARCH x86_64

Installation

So for MySQL Mariadb Packages as MySQL-Server and would install like mentioned below.

[root@archlinux ~]# pacman -S mariadb
resolving dependencies...
looking for conflicting packages...

Packages (8) boost-libs-1.65.1-2  jemalloc-1:5.0.1-3  libevent-2.1.8-1  libmariadbclient-10.1.29-1  libxml2-2.9.7+4+g72182550-2  lzo-2.10-1  mariadb-clients-10.1.29-1  mariadb-10.1.29-1

Total Download Size:    36.65 MiB
Total Installed Size:  254.79 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages...
 lzo-2.10-1-x86_64                      82.1 KiB  73.3K/s 00:01 [###########] 100%
 libevent-2.1.8-1-x86_64               250.2 KiB   112K/s 00:02 [###########] 100%
 libmariadbclient-10.1.29-1-x86_64       4.5 MiB   200K/s 00:23 [###########] 100%
 jemalloc-1:5.0.1-3-x86_64             274.5 KiB   241K/s 00:01 [###########] 100%
 mariadb-clients-10.1.29-1-x86_64     1464.6 KiB   215K/s 00:07 [###########] 100%
 libxml2-2.9.7+4+g72182550-2-x86_64   1265.4 KiB   169K/s 00:07 [###########] 100%
 boost-libs-1.65.1-2-x86_64              2.3 MiB   174K/s 00:14 [###########] 100%
 mariadb-10.1.29-1-x86_64               26.5 MiB   235K/s 01:55 [###########] 100%
(8/8) checking keys in keyring                                  [###########] 100%
(8/8) checking package integrity                                [###########] 100%
(8/8) loading package files                                     [###########] 100%
(8/8) checking for file conflicts                               [###########] 100%
(8/8) checking available disk space                             [###########] 100%
:: Processing package changes...
(1/8) installing lzo                                            [###########] 100%
(2/8) installing libmariadbclient                               [###########] 100%
(3/8) installing jemalloc                                       [###########] 100%
Optional dependencies for jemalloc
    perl: for jeprof [installed]
(4/8) installing mariadb-clients                                [###########] 100%
(5/8) installing libxml2                                        [###########] 100%
(6/8) installing boost-libs                                     [###########] 100%
Optional dependencies for boost-libs
    openmpi: for mpi support
(7/8) installing libevent                                       [###########] 100%
Optional dependencies for libevent
    python2: to use event_rpcgen.py
(8/8) installing mariadb                                        [###########] 100%
:: You need to initialize the MariaDB data directory prior to starting
   the service. This can be done with mysql_install_db command, e.g.:
   mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Optional dependencies for mariadb
    galera: for MariaDB cluster with Galera WSREP
    perl-dbd-mysql: for mysqlhotcopy, mysql_convert_table_format and mysql_setpermission
:: Running post-transaction hooks...
(1/3) Updating system user accounts...
(2/3) Creating temporary files...
(3/3) Arming ConditionNeedsUpdate...

After installation of, we could verify this through Query pacman.

[root@archlinux ~]# pacman -Q mariadb mariadb-clients
mariadb 10.1.29-1
mariadb-clients 10.1.29-1

Start Mariadb Service

Before strat of service, run below command

[root@archlinux ~]#  mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...

Now start Mariadb service.

[root@archlinux ~]# systemctl start mariadb

Now should follow secure like in below mentioned output.

[root@archlinux ~]# /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

So now Mariadb is installed and up and running on Archlinux machine as required . Let’s make it available on boot time.


[root@archlinux ~]# systemctl enable mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service -> /usr/lib/systemd/system/mariadb.service.

We can login locally on MySQL to work on its SQL console.

[root@archlinux ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.1.29-MariaDB MariaDB Server

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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

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