Skip to main content

Posts

Showing posts with the label mysqld

Set SELinux contexts for MySQL Server for datadir, logdir, errolog, pid, socket, port

Set SELinux contexts for MySQL Server for datadir, logdir, errolog, pid, socket, port: semange help: semanage -h semanage fcontext -h List the current MySQL contexts: #semanage fcontext -l | grep -i mysql List port available for MySQL: #semanage port -l | grep mysql Add port to mysqld template: #semanage -a -t mysqld_port_t -p tcp 3375 Add port range to mysqld template: #semanage port -a -t mysqld_port_t -p tcp 35000-38000 Remove the mysql templete tcp port: #semanage port -d -t mysqld_port_t -p tcp 3375 Set the data directory context: Default location for data directory - /var/lib/mysql/, the SELinux context used is mysqld_db_t. # semanage fcontext -a -t mysqld_db_t "/path/to/my/custom/datadir(/.*)?" # restorecon -Rv /path/to/my/custom/datadir Set the log directory context: # semanage fcontext -a -t mysqld_db_t "/path/to/my/custom/logdir(/.*)?" # restorecon -Rv /path/to/my/custom/logdir Set error log file context: The default location for RedHat RPMs is...

Can not start mysqld using systemctl | Permission Denied

Can't start mysqld using systemctl:  | Permission Denied 01. Check SELinux is enforced or not using following command, if the value is enforced means SELinux is enforced. #getenforce 02. Edit file /etc/selinux/config and set SELINUX=permissive 03. Reboot server, and type following command to see value permissive. #getenforce 05. Check status using following command #sestatus 04. Execute following command to start mysqld #sysetmctl start mysqld Explore more how to disable SELinux at following link https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/security-enhanced_linux/sect-security-enhanced_linux-working_with_selinux-changing_selinux_modes