SELinux File Context Setting the MySQL Data Directory Context Setting the MySQL Error Log File Context Setting the PID File Context Setting the Unix Domain Socket Context Setting the secure_file_priv Directory Context 1604 semanage fcontext -a -t mysqld_db_t "/var/lib/mysql-files/(/.*)?" semanage fcontext -a -t mysqld_var_run_t "/path/to/my/custom/mysql\.sock" restorecon -Rv /path/to/my/custom/mysql.sock semanage fcontext -a -t mysqld_var_run_t "/path/to/my/custom/pidfile/directory/.*?" restorecon -Rv /path/to/my/custom/pidfile/directory semanage fcontext -a -t mysqld_log_t "/path/to/my/custom/error.log" restorecon -Rv /path/to/my/custom/error.log semanage fcontext -a -t mysqld_db_t "/path/to/my/custom/datadir(/.*)?" restorecon -Rv /path/to/my/custom/datadir semanage fcontext -a -t mysqld_db_t "/path/to/my/custom/logdir(/.*)?" restorecon -Rv /path/to/my/custom/logdir If you enabled the use of this directory by setting  secure_file_priv , you may need to set the context like so: Installing the MySQL Server RPM creates a  /var/lib/mysql-files/  directory but does not set the SELinux context for it. The  /var/lib/mysql-files/  directory is intended to be used for operations such as  SELECT ... INTO OUTFILE . For MySQL versions since 5.6.34, 5.7.16, and 8.0.11. If you edit the configuration file to use a different location, you may need to set the context for the new location. For example: The default location for the Unix domain socket is  /var/lib/mysql/mysql.sock ; and the SELinux context type used is  mysqld_var_run_t . If you edit the configuration file to use a different location, you may need to set the context for the new location. For example: The default location for the PID file is  /var/run/mysqld/mysqld.pid ; and the SELinux context type used is  mysqld_var_run_t . If you edit the configuration file to use a different location for the data directory, or for any of the files normally in the data directory (such as the binary logs), you may need to set the context for the new location. For example: The default location for RedHat RPMs is  /var/log/mysqld.log ; and the SELinux context type used is mysqld_log_t . If you edit the configuration file to use a different location, you may need to set the context for the new location. For example: The default data directory location is  /var/lib/mysql/ ; and the SELinux context used is  mysqld_db_t .