If you want to allow mysqld to have write access on the mysql directory Then you need to change the label on mysql Do # semanage fcontext -a -t FILE_TYPE 'mysql' where FILE_TYPE is one of the following: bpf_t, cifs_t, container_file_t, container_var_lib_t, fusefs_t, hugetlbfs_t, nfs_t, svirt_home_t, tmpfs_t, virt_home_t. Then execute: restorecon -v 'mysql'
If you believe that mysqld should be allowed write access on the mysql directory by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing: # ausearch -c 'mysqld' --raw | audit2allow -M my-mysqld # semodule -X 300 -i my-mysqld.pp
Additional Information: Source Context system_u:system_r:container_t:s0:c114,c1019 Target Context system_u:object_r:mnt_t:s0 Target Objects mysql [ dir ] Source mysqld Source Path mysqld Port <Unknown> Host ip-172-31-54-198 Source RPM Packages Target RPM Packages SELinux Policy RPM selinux-policy-targeted-40.22-1.fc40.noarch Local Policy RPM selinux-policy-targeted-40.22-1.fc40.noarch Selinux Enabled True Policy Type targeted Enforcing Mode Enforcing Host Name ip-172-31-54-198 Platform Linux ip-172-31-54-198 6.8.11-300.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 27 14:53:33 UTC 2024 x86_64 Alert Count 1 First Seen 2024-07-13 11:16:08 CST Last Seen 2024-07-13 11:16:08 CST Local ID b331ca4f-5699-4d11-94d2-84638e0f0f8a
Raw Audit Messages type=AVC msg=audit(1720840568.80:300): avc: denied { write } for pid=3596 comm="mysqld" name="mysql" dev="nvme0n1p4" ino=9437365 scontext=system_u:system_r:container_t:s0:c114,c1019 tcontext=system_u:object_r:mnt_t:s0 tclass=dir permissive=0