• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System BSD

Configure MariaDB on OpenBSD 6

How VPS by How VPS
September 1, 2019
in BSD
0
0
SHARES
39
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Preparations
  2. Step 1: Install MariaDB
  3. Step 2: Enable MariaDB to start at system boot
  4. Step 3: Start MariaDB
  5. Step 4: Performance tweak (optional)
  6. Step 5: Secure the installation
  7. Step 6: Change MariaDB socket location
  8. Step 7: Start MariaDB manually
  9. Step 8: Test MariaDB
  10. Step 9: Create soft links
  11. Conclusion
  12. Want to contribute?


In this article, I’ll show you how to install MariaDB on OpenBSD 6 and configure it to be accessible to a chrooted web server (Apache or Nginx). You will also learn how to make make MariaDB available to non-chrooted applications.

Note: All commands in this tutorial need to be executed with root privilege in a command line window.

Steps were tested on OpenBSD 6.1 AMD64 installation.

Preparations

Make sure the environment variable PKG_PATH is configured.

echo $PKG_PATH

If it’s empty, configure it with the following command:

export PKG_PATH=http://ftp3.usa.OpenBSD.org/pub/OpenBSD/$(uname -r)/packages/$(uname -m)/

Step 1: Install MariaDB

pkg_add -v mariadb-server

Step 2: Enable MariaDB to start at system boot

rcctl enable mysqld

Step 3: Start MariaDB

/usr/local/bin/mysql_install_db

Step 4: Performance tweak (optional)

If your MariaDB is expected to serve a large amount of traffic, append the following lines to the file /etc/login.conf:

 mysqld:/
   :openfiles-cur=1024:/
    :openfiles-max=2048:/
    :tc=daemon:

Run the following command to generate the binary format of the login.conf file.

cap_mkdb /etc/login.conf

Step 5: Secure the installation

Run the secure installation command to make MariaDB even harder to compromise.

/usr/local/bin/mysql_secure_installation

Answer questions as prompted to set the root password, remove the test database and disable the remote root login. The initial password for root is blank.

Step 6: Change MariaDB socket location

Change the MariaDB socket location so that it’s accessible from a chrooted environment.

The default httpd in base or nginx in port are chrooted to /var/www, so let’s put the socket in /var/www/var/run/mysql/mysql.sock, so that it appears to be /var/run/mysql/mysql.sock for the chrooted web server.

Create the directory:

install -d -m 0711 -o _mysql -g _mysql /var/www/var/run/mysql

Edit /etc/my.cnf. In both the [client] section, and the [mysqld] section, change the line that reads:

socket = /var/run/mysql/mysql.sock

To:

socket = /var/www/var/run/mysql/mysql.sock

Step 7: Start MariaDB manually

 rcctl start mysqld

Step 8: Test MariaDB

Now test MariaDB by running the following command.

  mysql -uroot -p

Check if you can login with the password you set in the previous step.

Step 9: Create soft links

We need to create soft links for the mysql folder to make MariaDB accessible for non-chrooted applications. After having changed mysql.sock to the /var/www/var/run/mysql directory, some non-chrooted applications may not able to find it. If that’s the case, we can resolve it by creating a soft link to /var/www/var/run/mysql directory in /var/run/ (the default mysql.sock location).

 ln -s /var/www/var/run/mysql /var/run/

Now to make this change permanent. When OpenBSD starts, it clears everything under the /var/run directory, so we need to re-create the soft link at every reboot. We can do this by putting the command from step 9 in a file called /etc/rc.local. This file will be executed by the startup script at the end of the startup process. The /etc/rc.local file does not exist by default. You can create one by copying from the example file shipped with the OpenBSD, and appending the soft link to it.

cp /etc/examples/rc.local /etc/
echo "ln -s /var/www/var/run/mysql /var/run/" >> /etc/rc.local

Conclusion

That’s it. Your MariaDB server is now good to go.

Another note regarding MariaDB is the max_allowed_packet setting in /etc/my.cnf. The default value is 1M for [mysqld] section. If you encounter problems when importing a dump file from another server, try increasing it to 16M or 64M, and then restarting MariaDB.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

HTMLDoc: PDF From HTML Markup (UNIX FreeBSD)

Next Post

How to Install Directus 6.4 CMS on a FreeBSD 11 FAMP VPS

Next Post

How to Install Directus 6.4 CMS on a FreeBSD 11 FAMP VPS

Leave a Reply Cancel reply

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

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet