Install and configure MariaDB on FreeBSD for remote access

Warning!

This configuration may be not safe for production! Use with warning.

Steps

Install MariaDB

pkg update
pkg install mariadb105-client mariadb105-server
echo 'mysql_enable="YES"' >> /etc/rc.conf
    

Configure bind address

# /usr/local/etc/mysql/conf.d/server.cnf
# In section [mysqld]:

bind-address = YOUR_OUTSIDE_ADDRESS
    

Create users and databases

# From mysql query:

CREATE USER myuser;
CREATE DATABASE mydatabase;
USE mydatabase;
CREATE TABLE mytable (
  id MEDIUMINT AUTO_INCREMENT PRIMARY KEY,
  text VARCHAR(50)
);
    

Add privileges

# From mysql query:

GRANT SELECT, INSERT ON mydatabase.* TO myuser@'%' IDENTIFIED BY 'my-password' WITH GRANT OPTION;
    

Additional Links

MariaDB Basics
CREATE USER reference
MariaDB remote access
GRANT reference