1

I changed the tmp directory of the mysql configuration to a mounted disk and on service mysql restart I get following error:

Can't create/write to file '/mnt/temp/something' (Errcode: 13)

To my understanding, Error Code 13 refers to file permission error.

But strange part is:

  1. temp directory owner is already mysql and file permission is 1777

    drwxrwxrwt 2 mysql mysql 4.0K Nov 14 08:34 temp/

  2. I am able create file in the location with a non root user.

  3. There is 600 Gb of space on mnt so that should not be an issue.

  4. I can create tmp directory easily on root disk

/etc/mysql/my.cnf:

user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /mnt/mysql
tmpdir          = /mnt/temp
#tmpdir         = /var/tmp

Is creating a tmp directory on a mounted disk not allowed? Or else what am I doing wrong? Pls help.

Ut xD
  • 238
  • 1
  • 5
  • 13
  • What is your Linux distribution? – Michael Hampton Nov 14 '14 at 08:56
  • Its Ubuntu 12.04. Let me add that in tag too – Ut xD Nov 14 '14 at 08:58
  • What file-system is `/mnt/temp` formatted as? e.g. what is the output of the `mount`command? Second your my.cnf has now two tmpdir options. In that case the last one should take precedence. You can set multiple paths, according to the [manual](http://dev.mysql.com/doc/refman/5.0/en/temporary-files.html) the `tmpdir` option can be set to a list of several paths that are used in round-robin fashion, but those paths should be separated by colon characters (`:`). – HBruijn Nov 14 '14 at 09:38
  • @HBruijn /mnt 's disk format is `ext3` while disk format of `/` is `ext4`. Output of mount is `/dev/xvdb on /mnt type ext3 (rw)` Also, mysql's data directory is also on mnt so that should not be an issue. And the other tmp directory is commented, I have updated the question reflecting the same. – Ut xD Nov 14 '14 at 09:47
  • What are the permissions of `/mnt`? – Tero Kilkanen Nov 14 '14 at 10:55
  • @TeroKilkanen drwxr-xr-x – Ut xD Nov 15 '14 at 05:44

1 Answers1

2

So this is a little old, but I just solved a similar problem, myself (Using /mnt/tmp as the system temp dir) and had to figure out why MySQL wouldn't start up.

You're probably running up against the AppArmor settings that prevent MySQL from using directories on the /mnt drive. You'll need to add your new tmp path to the MySQL app armor list of allowed paths.

If you look in your syslog, you'll probably see messages looking something like this every time you try to start the mysql server:

type=1400 audit(1425343954.203:23): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/mysqld" name="/mnt/tmp/ibMXP5lg" pid=16418 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=106 ouid=106

In this case, You'll need to edit the file:

/etc/apparmor.d/usr.sbin.mysqld

And add the lines:

/mnt/tmp/ r,
/mnt/tmp/** rwk,

to the file. Then just restart AppArmor:

$ sudo service apparmor restart
noysh
  • 36
  • 3