Install: pkg_add mariadb-server
Boot startup: rcctl enable mysqld
Make sure mysqld starts first: rcctl order mysqld
cat <<EOF> /etc/my.cnf
[client-server]
#socket=/var/run/mysql/mysql.sock
#port=3306
# This will be passed to all MariaDB clients
[client]
#password=my_password
# The MariaDB server
[mysqld]
expire_logs_days = 3
#skip-networking
#max_allowed_packet = 16M
# To listen to all network addresses, use "bind-address = *"
bind-address=localhost
# Directory where you want to put your data
data=/mnt/mysql
# This is the prefix name to be used for all log, error and replication files
#log-basename=mysqld
# Logging
#general-log
#slow_query_log
EOF
Initialize mysql:
mariadb-install-db
# crypto partition (optional)
mariadb-install-db --datadir=/mnt/mysql
rcctl start mysqld
mariadb-secure-installation
Create a database:
mysql -u root -p
CREATE DATABASE <dbname> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL ON <dbname>.* TO '<dbname>'@'localhost' IDENTIFIED BY '<password>';
FLUSH PRIVILEGES;
rcctl start mysqld
mysql_upgrade -h 127.0.0.1 -p