MySQL errno 13 on OSX: it’s a permissions problem. (Yes, this is technical. Move on.)

This is really techy, and only for those who find themselves in the same situation as me, frantically searching Google for some nugget. No media or financial info here – ignore and move on.

Here’s what happened. I thought one of my databases needed another table (don’t they all?). So I clicked in CocoaMySQL to add a table. Nuh-uh: /* ERROR 14:48:53 Can't create table '#sql-ca_36' (errno: 13) */

Uh? Tried again in a different program, MySQL Administrator. Same result. Tried while logged into to MySQL as root. No luck. So I spent some time tweaking permissions in the administrator. No luck. Clearly, MySQL couldn’t change the structure of its own tables. That seemed a bit remiss.

Puzzled, I searched around a bit – but got nothing that seemed helpful. Except some people had had bad installs… hmm.. Aha! I’d had a problem a couple of months back where a key system program got corrupted – everything else was fine, so I’d done an Archive and Install, and just dragged over the folders holding MySQL (and its data: it all lives in the folder referenced by /usr/local/mysql (get there by going to the Finder and typing Cmd-Shift-G and then enter /usr/local/) – which is usually itself a symbolic link to the folder holding your version of MySQL.

The Apple guide to installing OSX is intended for server but works perfectly well for your own. The key lines are those about getting the right permissions:

Note that at this point everything is owned by root meaning the mysql account wont be able to write to the databases under var/ nor be able to create the mysql UNIX socket in the run/ directory. Since we want to run the MySQL database under the mysql account, and not under the root account, we need to change the group association of /usr/local/mysql to the group mysql, and the ownership of /usr/local/mysql/run and /usr/local/mysql/var to the mysql account, as follows:

sudo chgrp -R mysql /usr/local/mysql
sudo chown -R mysql /usr/local/mysql/run /usr/local/mysql/var

That fixes things. But then you need to apply them to the enclosed items too – see the popup at right. Apply to enclosed items, and you’re done. There. A bit of a pain. But maybe it’ll sort someone out who’s flummoxed.

2 Comments

  1. Actually, I enjoyed that. It showed me what I’m missing by watching television. :)

    wg

  2. Try dpkg-reconfigure mysql-server-5.0. Should clear things up:) At least if you are running Debian.

Comments are closed.