At the moment, MySQL Server is using /tmp as it's temporary directory, and I'd like to change that, because it's running into storage issues.

Following this post: https://encylia.com/2015/02/06/how-to-change-the-mysql-tmp-location-on-centos/ as I'm on Scientific Linux and generally CentOS works pretty well as an analog, I've done the following, all under sudo:

mkdir /home/mysqltmp

chmod 1777 /home/mysqltmp

nano /etc/my.cnf

Add below line under the [mysqld] section and save the file

systemctl restart mysqld

This restart fails. If I restore the old my.cnf without the change, it works perfectly, which suggests to me that there's a problem either with the configuration file itself, or with how I've setup permissions, and given my (limited) Linux experience, I'm pretty sure that it's a permissions problem.

UPDATE: Looking at mysqld.log, it appears this is indeed a permissions issue:

2018-05-16T00:01:05.211853Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.22) starting as process 5929 ...
2018-05-16T00:01:05.214159Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-05-16T00:01:05.214186Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-16T00:01:05.214191Z 0 [Note] InnoDB: Uses event mutexes
2018-05-16T00:01:05.214194Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-05-16T00:01:05.214197Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-16T00:01:05.214202Z 0 [Note] InnoDB: Using Linux native AIO
2018-05-16T00:01:05.214382Z 0 [Note] InnoDB: Number of pools: 1
2018-05-16T00:01:05.214459Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysqld: Can't create/write to file '/home/mysqltmp/ibAcknwl' (Errcode: 13 - Permission denied)
2018-05-16T00:01:05.214535Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 13
2018-05-16T00:01:05.214542Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2018-05-16T00:01:05.214548Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2018-05-16T00:01:05.214551Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-05-16T00:01:05.214554Z 0 [ERROR] Failed to initialize builtin plugins.
2018-05-16T00:01:05.214557Z 0 [ERROR] Aborting

Does anyone see what I'm doing wrong?

Update 2: This does appear to be an selinux thing. chown does not fix the problem, and in the audit logs there's a number of AVC denied {write} messages for that directory.

selinux is entirely opque to me - is there a fix for this?

  • does sudo chown mysql.mysql /home/mysqltmp help? Though I am more inclined for it to be a SELinux thing.... – Rui F Ribeiro May 16 '18 at 8:00
  • See update. It's an SELinux thing. – Fomite May 17 '18 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.