I read that using RAM for MySQL's temporary tables should improve performance. I tried to create /etc/mysql/conf.d/local.cnf with the contents:

tmpdir = /run/shm

But restarting mysql fails, with the error log saying:

140711 11:14:49 [Warning] Using unique option prefix myisam-recover instead of
myisam-recover-options is deprecated and will be removed in a future release. Please
use the full name instead.
140711 11:14:49 [Note] Plugin 'FEDERATED' is disabled.
140711 11:14:49 InnoDB: The InnoDB memory heap is disabled
140711 11:14:49 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140711 11:14:49 InnoDB: Compressed tables use zlib 1.2.8
140711 11:14:49 InnoDB: Using Linux native AIO
/usr/sbin/mysqld: Can't create/write to file '/run/shm/ibfkgz7Z' (Errcode: 13)
140711 11:14:49  InnoDB: Error: unable to create temporary file; errno: 13
140711 11:14:49 [ERROR] Plugin 'InnoDB' init function returned error.
140711 11:14:49 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140711 11:14:49 [ERROR] Unknown/unsupported storage engine: InnoDB
140711 11:14:49 [ERROR] Aborting

140711 11:14:49 [Note] /usr/sbin/mysqld: Shutdown complete

Error code 13 is "Permission denied". But considering the following output, I don't see what could be the problem.

$ ls -ld /run /run/shm
drwxr-xr-x 32 root root 1040 jul 11 09:42 /run
drwxrwxrwt  3 root root  280 jul 11 09:41 /run/shm
  • 1
    see askubuntu.com/questions/169495/… for an explaination of shm – Rinzwind Jul 11 '14 at 8:13
  • What size has your /run/shm (dh -h) ? Also, do you have specific innodb_* parameters in you Mysql config files ? – Benoit Jul 11 '14 at 9:35
  • Also, I wouldn't advise you to do so (using RAM as temp directory), because even if it is faster than disk, you have less place for temporary tables. Unless you know exactly the amount of space all your temporary tables will occupy, let your tmpdir on the disk. – Benoit Jul 11 '14 at 9:45
  • Size is 3,8GB, 1% used. grep -r innodb /etc/mysql gives nothing. – Arild Jul 11 '14 at 11:46

There is a dependency from apparmor security settings

You have to change configs to get tmpdir into RAM

File: /etc/mysql/my.cnf

tmpdir = /run/shm/mysql

File: /etc/apparmor.d/usr.sbin.mysqld add a line alongside with other filesystem rules

/run/shm/mysql/* rw,

And shell steps to GTD

service apparmor restart
mkdir /run/shm/mysql
chown mysql:mysql /run/shm/mysql
chmod -R 777 /run/shm/mysql
service mysql restart

Mysql daemon should be up and running after all.

PS. Don't forget to add a line to /etc/rc.local for getting system working after reboot

mkdir /run/shm/mysql && chown mysql:mysql /run/shm/mysql && chmod -R 777 /run/shm/mysql
| improve this answer | |
  • 1
    Strange, I wasn't interested in something like to move this to a RAM-DISK. But after an apt update/upgrade my MariaDB didn't has started anymore. Reason was, that it now assumed, that this should be now on this RAM-DISK location. Thanks for the quick and easy solution! – Sascha May 25 at 7:57

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.