Install and Configure MariaDB Database on OpenBSD 7

Thank you for keeping it techviewleo, we really appreciate your continued support, and thank you for making us your number one stop for all your “How to” in the tech world. In our guide today we will look at install and configure MariaDB on OpenBSD 7. In our previous article, we looked at how to How to Install OpenBSD 7 on Proxmox VE. Please visit the link, and install OpenBSD 7 for you to continue with this guide.

MariaDB is a free and open-source relational database. It is a community-developed commercially supported fork of the MYSQL Relational Database Management System (RDMS). It is the predecessor of the famous MYSQL Database and was developed by the MYSQL developers. It has grown to become the most famous and popular Relational Database in the world supporting some of the giant companies e.g Google, Wikipedia, and Word Press. MariaDB has an SQL interface for accessing data. The greatest benefit that MariaDB offers over the commercial SQL database servers is that it is completely free to download and use. In addition, Organizations can now depend on a single complete database for all their needs, whether on commodity hardware or their cloud of choice. The latest LTS stable release is version 11.8.3 while the initial release was on October 2009. MariaDB is default in most Linux distributions and its compatible with Oracle Database.

šŸ”„ TRENDING - Our #1 Selling eBook

Mastering KVM Virtualization - The Ultimate eBook

From home labs to production clouds - master KVM Host management, automating KVM administration using Terraform, Vagrant, and cloud automation. This eBook will enable you to build scalable virtual infrastructure that works whether you're learning at home or deploying enterprise solutions. Get your full copy today

Only $10 $20
Get Instant Access →

MariaDB Features

An outline of the MariaDB features:

  • It is fast.
  • It is scalable.
  • It is robust
  • It is cross platform (Linux , Windows and MacOS)
  • It is very agile
  • It is multithreaded SQL database.
  • It has a rich ecosystem of storage engines, plugins etc.
  • It is programmed in C, C++ and Perl.
  • It is very versatile for a wide variety of use cases.
  • It includes GIS and JSON in the latest releases.

Install MariaDB Database Server on OpenBSD 7

The article assumes your system is running on OpenBSD 7. Follow the steps below to Install MariaDB on OpenBSD 7.

All the commands in this guide are executed as the root user.

Step 1 – Install MariaDB Server on OpenBSD 7

Log in as a root user.

Search for packages i.e MariaDB Server and Client:

Run the commands below.

# Searching for MariaDB database package
pkg_info -Q mariadb   

# Searching for MySQL database server package
pkg_info -Q mysql

The sample output shows the available packages for installation. Please note I have edited my output.

Install MariaDB database server on OpenBSD 7

Use the command pkg_add to install the package.

openbsd# pkg_add -V mariadb-server 
quirks-7.147 signed on 2025-10-25T13:57:07Z
mariadb-server-11.4.7v1:snappy-1.1.10p2: 2/8
mariadb-server-11.4.7v1:mariadb-client-11.4.7v1: 3/8
mariadb-server-11.4.7v1:nghttp2-1.67.1: 4/11
mariadb-server-11.4.7v1:nghttp3-1.12.0: 5/11
mariadb-server-11.4.7v1:ngtcp2-1.16.0: 6/11
mariadb-server-11.4.7v1:curl-8.16.0: 7/11
mariadb-server-11.4.7v1:coreutils-9.7: 8/11
mariadb-server-11.4.7v1:p5-Params-Util-1.102: 9/19
mariadb-server-11.4.7v1:p5-Math-Base-Convert-0.11p0: 10/19
mariadb-server-11.4.7v1:p5-Module-Runtime-0.016p0: 11/19
mariadb-server-11.4.7v1:p5-Clone-0.47: 12/19
mariadb-server-11.4.7v1:p5-SQL-Statement-1.414: 13/19
mariadb-server-11.4.7v1:p5-FreezeThaw-0.5001p0: 14/20
mariadb-server-11.4.7v1:p5-MLDBM-2.05p0: 15/20
mariadb-server-11.4.7v1:p5-Net-Daemon-0.49: 16/21
mariadb-server-11.4.7v1:p5-PlRPC-0.2020p0: 17/21
mariadb-server-11.4.7v1:p5-DBI-1.644: 18/21
mariadb-server-11.4.7v1:p5-DBD-MariaDB-1.23: 19/21
mariadb-server-11.4.7v1:findutils-4.10.0p0: 20/21
mariadb-server-11.4.7v1: 21/21
The following new rcscripts were installed: /etc/rc.d/mysqld
See rcctl(8) for details.
New and changed readme(s):
	/usr/local/share/doc/pkg-readmes/mariadb-server
Install MariaDB Client on OpenBSD 7

To install the MariaDB Client, run the following command.

openbsd# pkg_add -v mariadb-client 
Update candidates: quirks-7.147 -> quirks-7.147
quirks-7.147 signed on 2025-10-25T13:57:07Z

The client has been updated.

Step 2 – Enable and start MariaDB server at boot time on OpenBSD 7

To start daemon and services in OpenBSD 7, we use the rcctl command.

Enable MariaDB to start on boot

Enable the service to automatically start on reboot.

# rcctl enable mysqld

To initialize MariaDB

To initialize MariaDB, run the mysql_install_db command

openbsd# /usr/local/bin/mariadb-install-db
WARNING: The host 'openbsd.home.cloudlabske.io' could not be looked up with /usr/local/bin/resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MariaDB version. The MariaDB daemon, mariadbd, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MariaDB privileges !
Installing MariaDB/MySQL system tables in '/var/mysql' ...
OK


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is _mysql@localhost, it has no password either, but
you need to be the system '_mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at https://mariadb.com/kb

You can start the MariaDB daemon with:
/etc/rc.d/mysqld start

Please report any problems at https://mariadb.org/jira

The latest information about MariaDB is available at https://mariadb.org/.

Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

Run the commands below to start and stop the service.

# rcctl start mysqld
# rcctl stop mysqld

For a restart you can use the commands shared below;

# rcctl restart mysqld

Run the following commands to check the service status:

# rcctl check mysqld   

If you get an error in checking the status, please configure the file /etc/my.cnf to look like this. This is the default file where all necessary parameters are configured. For example, you can enable the default port 3306 by removing the # symbol as shown in the screenshot.

Configure the bind-address from localhost to 127.0.0.1 as shown above. Save and exit from the editor.

Verify that the MariaDB service is running and port 3306 is open:

openbsd# netstat -f inet -na | grep 3306
tcp          0      0  127.0.0.1.3306         *.*                    LISTEN

Step 3 – Secure MariaDB Database

To secure the MariaDB with a password, we will run the mysql_secure_installation script. This script removes the default database and settings.

openbsd# mariadb-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
haven't set the root password yet, you should just press enter here.

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

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

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the 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!

Step 4 – Test MariaDB installation on OpenBSD 7

We will test our installation with the following MySQL command.

# mariadb -u root -p

Supply the password created in the above step.

Create a new sample database named testdb:

MariaDB [(none)]> CREATE DATABASE testDB;
Query OK, 1 row affected (0.004 sec)

Create a database user and a password for the user:

MariaDB [(none)]> CREATE USER 'openbsd'@'localhost' IDENTIFIED BY 'STRONGDBPASSWORD';
Query OK, 0 rows affected (0.003 sec)

Grant the user full permissions to the testdb database.

MariaDB [(none)]> USE testDB;
Database changed

MariaDB [testDB]> GRANT ALL PRIVILEGES ON testDB.* TO 'openbsd'@'localhost';
Query OK, 0 rows affected (0.002 sec)

Reload the privileges.

MariaDB [testdb]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
MariaDB [testDB]> QUIT
Bye

Summary of the commands above:

Login to the database as the standard user we just created:

# mariadb -u openbsd -p

Supply the STRONG-PASSWORD for the openbsd to login. Then show your databases. As shown below.

Type “exit” or “quit” to exit the console.

Wrap-up

In the guide, we have successfully installed and configured MariaDB Database server on OpenBSD 7. If you have any questions, please do let us know in the comment section below.

More helpful resources:

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Unlock the Right Solutions with Confidence

At CloudSpinx, we don’t just offer services - we deliver clarity, direction, and results. Whether you're navigating cloud adoption, scaling infrastructure, or solving DevOps challenges, our seasoned experts help you make smart, strategic decisions with total confidence. Let us turn complexity into opportunity and bring your vision to life.

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

The best place to start is the beginning. In the introduction, we will familiarise ourselves with the definition of terms […]

In this guide, we will systematically go through how to install OpenBSD 7 on a Hypervisor i.e Proxmox VE. But […]

This tutorial will show you how to install iRedMail Email Server on a Linux server running Ubuntu 24.04|22.04. iRedMail is […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.