Fixing MySQL error 13 on Mac OS X 10.6.x

I’m using XAMPP on Mac OS X 10.6.3.
Once I had to restore permissions and after that I started getting this error, every time I try to access InnoDB tables:

Can’t create file ‘/var/folders/aX/aXYUzZmoHruKTlzkbVLQdU+++TM/-Tmp-/#sql10aac_1_0.frm’ (errno: 13)

The problem was that my.cnf disappeared from the “/etc” folder, for some reason. This file should contain path to a MySQL temporary storage.
So, I performed the following simple steps to fix the issue:

1. Open Terminal

$ cd /etc
$ sudo nano my.cnf

Type this in:

[mysqld]
tmpdir=/usr/local/mysql/tmp

Control-X to save it.
Now go to /usr/local/mysql:

$ cd /usr/local/mysql
$ sudo mkdir tmp
$ sudo chown _mysql:wheel tmp
$ sudo chmod 755 tmp

Basically, I just created MySQL temporary storage folder and told MySQL where to find it.
Hope this article will help you if you’re having the same issue.

Filed in: Uncategorized