I found this walkthrough for me: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/SELinux_Users_and_Administrators_Guide/sect-Managing_Confined_Services-MariaDB-Confml_
You must install: yum install policycoreutils-python
Guide:
View SELinux context for default database for mysql:
~]
This displays mysqld_db_t, which is the default context element for the location of the database files. This context must be applied manually to the new database location that will be used in this example in order for it to function properly.
Stop the mysqld daemon:
~]
Create a new directory for the new database location. This example uses / mysql /:
~]
Copy the database files from the old location to the new location:
~]
Change ownership of this location to allow access to the mysql user and group. This sets up the traditional Unix permissions that SELinux will still observe:
~]
Run the following command to see the initial context of the new directory:
~]
The usr_t context of this newly created directory is currently not suitable for SELinux as the location of the MariaDB database files. When the context is changed, MariaDB will be able to function normally in this area.
Open the MariaDB main configuration file / etc / my.cnf with a text editor and change the datadir parameter to refer to the new location. In this example, the value to be entered is / mysql:
[mysqld] datadir=/mysql
Save this file and exit.
Run mysqld. The service should not start, and the failure message will be written to the / var / log / messages file:
~]
Work for mariadb.service failed. See "Systemctl status postgresql.service" and "journalctl -xn" for details.
However, if the audit daemon is started and the setroubleshoot service is running with it, the failure will be written to the /var/log/audit/audit.log file: SELinux prevents / usr / libexec / mysqld from “writing” access to / mysql. For complete SELinux messages. run sealert -l b3f01aff-7fa6-4ebe-ad46-abaef6f8ad71
The reason for this failure is that / mysql / is incorrectly marked for MariaDB data files. SELinux stops MariaDB from accessing content marked as usr_t. Follow these steps to resolve this issue:
Run the following command to add a context mapping for / mysql /. Please note that semanageutility is not installed by default. If it is not on your system, install policycoreutils-pythonpackage.
**~]
This mapping is written to / etc / selinux / targeted / contexts / files / file _contexts.local:
~]
/ MySQL (/.*)? system_u: object_r: mysqld_db_t: s0
Now use the restorecon utility to apply this context mapping to the running system:
**~]
Now that / mysql / location is tagged with the appropriate context for MariaDB, mysqldstarts:
~]
Confirm that the context has changed for / mysql /:
~]$ ls -lZ /mysql drwxr-xr-x. mysql mysql system_u:object_r:mysqld_db_t:s0 mysql
The location has been changed and marked, and mysqld has started successfully. At this point, all running services should be tested to confirm normal operation.