OpenBSD install MariaDB database server

How do I install MariaDB database servers on OpenBSD Unix operating systems?

Introduction: MariaDB is a drop in replacement for Oracle MySQL servers. MariaDB is a multithreaded SQL database with a command syntax very similar to mSQL. This page shows how to install MariaDB server on OpenBSD. There are two packages of MariaDB on OpenBSD 6.4
  1. mariadb-server – The MariaDB server.
  2. mariadb-client – The client side of MariaDB server including mysqlclient library and headers for the MariaDB client API.

How to search for MariaDB packages

Run the following pkg_info command along with grep command:
pkg_info -Q mariadb
Search for PHP client that can access mariadb server:
pkg_info -Q mariadb | grep php
How to search for MariaDB packages on OpenBSD

OpenBSD install MariaDB database server using pkg_add

Type the following pkg_add command to install MariaDB on OpenBSD 6.4:
# pkg_add -v mariadb-server
OR
$ doas pkg_add -v mariadb-server

How to install MariaDB client on OpenBSD

Simply run:
# pkg_add -v mariadb-client
OR
$ doas pkg_add -v mariadb-client

How to enable and start MariaDB server at boot time on OpenBSD

To configure and control daemons and services on OpenBSD use rcctl command

Enable MariaDB

# rcctl enable mysqld
OR
$ doas rcctl enable mysqld

Initialize MariaDB data directory

You need to run mysql_install_db command. It initializes the MariaDB data directory and creates the system tables:
# mysql_install_db

Configure MariaDB on OpenBSD 6.x

Start MariaDB service on OpenBSD

# rcctl start mysqld

Stop MariaDB service on OpenBSD

# rcctl stop mysqld

Restart MariaDB service on OpenBSD

# rcctl restart mysqld

Check MariaDB service status on OpenBSD

# rcctl check mysqld

Verify that MariDB service running and port is open

Run pgrep command to searche the process named mysqld:
# pgrep mysqld
Another option is to run ps command:
# ps aux | grep mysqld
Verify that TCP port 3306 is open using netstat command:
# netstat -f inet -na
# netstat -f inet -na | grep 3306

How to secure MariaDB installation

Run the following script:
# mysql_secure_installation

Securing MariaDB server installations to avoid compromising server

How to test MariaDB installation

Run the following mysql command:
mysql -u root -p

How to configure MariaDB on OpenBSD 6.4

Edit /etc/my.cnf file:
# vi /etc/my.cnf
For example, change IP address binding from localhost:
bind-address = 127.0.0.1
To LAN IP address 192.168.2.200:
bind-address = 192.168.2.200
Save and close the file. Restart mysqld service on OpenBSD:
# rcctl restart mysqld

How to open MariaDB port using PF firewall on OpenBSD

Simply add the following rule to /etc/pf.conf

pass in proto tcp from 192.168.2.0/24 to any port 3306 keep state

Test it and reload the rules:
# pfctl -v -nf /etc/pf.conf
# pfctl -v -f /etc/pf.conf

Conclusion

You learned how to set up and install MariaDB on OpenBSD. For more information see the official MariaDB site here and pkg_add page here and recommended MariaDB books here.

This entry is 2 of 5 in the Tutorial series. Keep reading the rest of the series:
  1. CentOS 8 install MariaDB
  2. OpenBSD install MariaDB database server
  3. RHEL 8 install MariaDB
  4. FreeBSD 11 install MariaDB
  5. Setup MariaDB SSL and secure connections from clients

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

Comments on this entry are closed.

  • 🐧 Vivek Gite Jan 17, 2019 @ 11:40

    See pf man page for more info:
    man pf
    man pfctl
    man 5 pf.conf

Comments are closed. Still have questions? Post it on our forum