This mapping is written to the /etc/selinux/targeted/contexts/files/file_contexts.local file: ~]# grep -i mysql /etc/selinux/targeted/contexts/files/file_contexts.local ~]# semanage fcontext -a -t mysqld_db_t "/mysql(/.*)?" If it missing on your system, install the policycoreutils-python package. Note that the semanageutility is not installed by default. Run the following command to add a context mapping for mysql. Perform the following steps to resolve this problem: SELinux is stopping MariaDB from having access to the content labelled as usr_t. The reason for this denial is that mysql is not labelled correctly for MariaDB data files. However, if the audit daemon is running and with him the setroubleshoot service, the denial will be logged to the /var/log/audit/audit.log file instead: SELinux is preventing `/usr/libexec/mysqld` "write" access on /mysql. See 'systemctl status rvice' and 'journalctl -xn' for details. The service should fail to start, and a denial message will be logged to the /var/log/messages file: ~]# systemctl start rvice In this example the value that should be entered is /mysql: Open the main MariaDB configuration file /etc/my.cnf with a text editor and modify the datadir option so that it refers to the new location. Once the context has been changed, MariaDB will be able to function properly in this area. The context usr_t of this newly created directory is not currently suitable to SELinux as a location for MariaDB database files. ![]() mysql mysql unconfined_u:object_r:usr_t:s0 mysql Run the following command to see the initial context of the new directory: ~]# ls -lZ /mysqlĭrwxr-xr-x. ![]() This sets the traditional Unix permissions which SELinux will still observe: ~]# chown -R mysql:mysql /mysql In this example, /mysql/ is used: ~]# mkdir -p /mysqlĬopy the database files from the old location to the new location: ~]# cp -R /var/lib/mysql/* /mysql/Ĭhange the ownership of this location to allow access by the mysql user and group. Stop the mysqld daemon: ~]# systemctl stop rviceĬreate a new directory for the new location of the database(s). This context will have to be manually applied to the new database location that will be used in this example in order for it to function properly. This shows mysqld_db_t which is the default context element for the location of database files. mysql mysql system_u:object_r:mysqld_db_t:s0 mysql View the SELinux context of the default database location for mysql: ~]# ls -lZ /var/lib/mysqlĭrwx. ![]() You must install: yum install policycoreutils-python I found this step by step guide working for me. So if you have selinux there are some additional steps. I just noticed a similar question, of which this is close to a duplicate of, which mentions some issues of doing that above with selinux enabled Server version: 5.5.18-log MySQL Community Server (GPL) Starting mysqld (via systemctl): # mysql -uroot Lrwxrwxrwx 1 root root 10 Feb 26 23:02 /var/lib/mysql -> ~]# service mysqld start # mv /var/lib/mysql/ ~]# ln -s /opt/mysql ~]# ls -la /var/lib/mysql My normal procedure is to stop mysql, move the directory contents, link the original, and restart mysqld. There are arguments for using a bind entry in /etc/fstab instead of a symlink, but this works for me. I can't confirm this from cpanel, as I don't have access, but this is an example from the console connected by ssh and sudo to root.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |