Where to Discuss?

Local Group


Goal: Setting-up LAMP stack with Artix OpenRC. Configure MariaDB.

MariaDB is MySQL compatible. So we use a lot of mysql reference here. Such as data path, service name and such.

Install MariaDB Packages

Just like any other stack we start with installing. Instead of ready to use docker, this time we install in system.

  • mariadb
  • mariadb-openrc
❯ sudo pacman -S mariadb mariadb-openrc
resolving dependencies...
looking for conflicting packages...

Packages (2) mariadb-10.11.2-1

Total Installed Size:  207.89 MiB

:: Proceed with installation? [Y/n] y
(2/2) checking keys in keyring                    
(2/2) checking package integrity                  
(2/2) loading package files                       
(2/2) checking for file conflicts                 
(2/2) checking available disk space               
:: Processing package changes...

LAMP OpenRC: Pacman: Install MariaDB Packages

What we need to care about is, whether the we should do additional task manually, or just leave it. Such as manual database setup.

(1/2) installing mariadb                          
:: You need to initialize the MariaDB data directory prior to starting
   the service. This can be done with mariadb-install-db command, e.g.:
   mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Optional dependencies for mariadb
    cracklib: for cracklib plugin [installed]
    curl: for ha_s3 plugin [installed]
    galera: for MariaDB cluster with Galera WSREP
    judy: for Open Query GRAPH (OQGraph) computation
    perl-dbd-mariadb: for mariadb-hotcopy,
    mariadb-convert-table-format and
    python-mysqlclient: for myrocks_hotbackup
    xz: lzma provider [installed]

LAMP OpenRC: Pacman: Install MariaDB Packages

And so init related stuff. Depend on the policy, some system require us to do stuff manually, for flexibility reason.

(2/2) installing mariadb-openrc                   
:: Running post-transaction hooks...
(1/3) Creating system user accounts...
(2/3) Creating temporary files...
(3/3) Displaying openrc service help ...
	==> Add a service to runlevel:
	rc-update add <service> <runlevel>
	==> Start/stop/restart a service:
	rc-service <service> <start/stop/restart>

LAMP OpenRC: Pacman: Install MariaDB Packages

Setup Database

This is my favorite. We actually can setup the database, with our own parameter.

❯ sudo mariadb-install-db \
  --user=mysql \
  --basedir=/usr \
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...

To start mariadbd at boot time you have to copy
support-files/mariadb.service to the right place for your system

LAMP OpenRC: Setup Database

The complete response is here. I guess you understand the reason why, I don’t dump them all in this article.

LAMP OpenRC: Setup Database

If your database is already exist, the command would response differently.

LAMP OpenRC: Setup Database

Running Service

Init handling is a must have knowledge in linux system. Init diversity is optional, depend on your taste, and distribution flavour. For OpenRC we have this two commands:

  • rc-update,
  • rc-service

We need to set that the mysql started automatically, at the default runlevel. We can reach this runlevel default after boot, or depend on your init management.

❯ sudo rc-update add mysql default
 * service mysql added to runlevel default

LAMP OpenRC: Service: Running Service

Of course the mysql is still not running, unless we have booted the system. That is why we have to start manually.

❯ sudo rc-service mysql status
 ERROR! MariaDB is not running

Now let’s get it started.

❯ sudo rc-service mysql start
Starting MariaDB.230321 17:40:51 mysqld_safe Logging to '/var/lib/mysql/andalan.err'.
230321 17:40:51 mysqld_safe Starting mariadbd daemon with databases from /var/lib/mysql
❯ sudo rc-service mysql status
SUCCESS! MariaDB running (32473)

LAMP OpenRC: Service: Running Service

We are sooo.. up and running…

Hard Reset

If you don’t have any necessary data, you can reset you database.

Sometimes it is necessary for new system. Just to make sure that a process is repeatable.

❯ sudo rc-service mysql stop
Shutting down MariaDB. SUCCESS! 
❯ sudo rm -rf /var/lib/mysql/

LAMP OpenRC: Hard Reset: Hard Reset

If you start, you will have an error. Of course, because we have no setup yet.

LAMP OpenRC: Hard Reset: Hard Reset

You will have to do setup procedure again.

❯ sudo mariadb-install-db \
    --user=mysql \
    --basedir=/usr \

Socks Issue

I was once encounter this sock issue.

❯ mariadb
ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)

LAMP OpenRC: Socks Issue

All I need to do is restart the service to get the sock.

LAMP OpenRC: Socks Issue

No need to logout or even reboot.



How I would I know that MariaDB works in my machine?

If everything fine, your MariaDB should show the versionn.

❯ mariadb --version
mariadb  Ver 15.1 Distrib 10.11.2-MariaDB, for Linux (x86_64) using readline 5.1

LAMP OpenRC: Test: MariaDB Version

We are ready.

What is Next 🤔?

Now it is time to examine SQL in MariaDB.

Consider continue reading [ LAMP - MariaDB Prompt ].

Thank you for reading.