Issue
similar questions have been asked before but they don't seem to work for me and I have a theory why that is (later in post).
Background: I have installed MySQL on my Fedora 31 to run a local server. Up to this point everything works as expected and I happily use my database. What I didn't consider is the fact that this database is using up some of my space, since the project I am working on is data-heavy, MySQL stopped running a query due to lack of space. I followed this Blog here to move the location of my directory in my main partition with plenty of space.
However, when restarting the server, it fails to do so. The error message given by systemctl status mysqld.service
is:
From various sources I got the feeling that this has something to do with the SELinux context. As described in the blog post, I changed the type, which is as the original type. Upon inspection I realised that the user aspect of the context is different (system_u for /var/lib/mysql vs confined_u for /new/directory/in/home). I suspect it has something to do with the difference, given that the permission seems to be denied.
My Question now is: How do I fix this? Can I change the user without repercussions? If so, how? Another thought of mine while typing this - am I missing something, potentially I might have tried to move my database within the same partition without gaining extra space. To answer this question I would need to know if in a standard fedora installation /var and /home are located on different partitions. Answers to this? If this is the case - how can I allocate more space to my database so I don't have any more trouble running it? I still have 770 GB free in my /home partition, so that really shouldn't be an issue. See the screenshot below for my current partitions:
any help would be greatly appreciated! Thank you
EDIT: Output of ls -laZ
Is
semanage fcontext
the same as chcon -R -t mysqld_db_t /data
? Because then I did chcon -t mysqld_db_t /home
, chcon -t mysqld_db_t /home/{username}
and chcon -R -t mysqld_db_t /home/{username}/mysql_data
. I didnt do anything beyond this, because I just followed the blog post without looking left and right. Any suggestions based on this?
Solution
The error is permission denied so its not a space issue.
Try: systemctls edit mysqld.service
Create:
[Service]
ProtectHome=false
Then systemctl start mysqld.service
If that fails, look back at selinux. What semanage fcontext
command was run? What restorecon
command? What exactly is ls -laZ {newdatadir}
?
Alternately to correct the space issue:
If /home is ext[34] you can reduce its size (filesystem and logical volume) and grow the root logical volume and filesytem.
Or 17G is enough sufficient use the swap volume like:
swapoff /dev/fedora.../swap
lvremove fedora.../swap
lvextend fedora.../root -L +17G
resize2fs /
in /etc/fstab remove swap entry (or replace with 1-2G file based swap)
Answered By - danblack Answer Checked By - Mildred Charles (WPSolving Admin)