Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The MySQL server won't start and is reporting the following error:

/usr/local/mysql/bin/mysqld: Can't create/write to file '/usr/local/mysql/data/James-Barnhills-Mac-Pro.local.pid' (Errcode: 13)
Can't start server: can't create PID file: Permission denied

All the permissions are set recursively as:

lrwxr-xr-x 1 _mysql wheel 27 Nov 22 09:25 mysql -> mysql-5.5.18-osx10.6-x86_64

but it won't start. I've tried reinstalling several times to no avail.

I'm running as root on Mac OS, and MySQL has read, write, and execute permissions on the "data" folder.

share|improve this question
    
ls -ld /usr/local/mysql/data/? –  quanta Nov 24 '11 at 2:35
    
drwxr-xr-x 13 _mysql wheel 442 Nov 24 09:04 mysql/data/ –  James Barnhill Nov 24 '11 at 15:11
    
ls -ld /usr/local/mysql-5.5.18-osx10.6-x86_64/? –  slillibri Dec 5 '11 at 1:27
    
@JamesBarnhill To expand on my earlier comment, make sure _mysql has x permissions to /usr/local/mysql-5.5.18-osx10.6-x86_64/, not just /usr/local/mysql as that is just a symlink. If you chmod +x /usr/local/mysql-5.5.18-osx10.6-x86_64/ it should start (at least that would match the working perms on my MBP). –  slillibri Dec 5 '11 at 1:54
    
I resolved this issue by running sudo chmod -R 0771 /usr/local/mysql-*, giving /usr/local/mysql-5.5.18-osx10.6-x86_64/ the permissions drwxrwx--x 18 _mysql wheel. –  James Barnhill Dec 5 '11 at 8:09
add comment

2 Answers

up vote 1 down vote accepted

The permission errors are because you have the directory set to the Octal Permission 0751. This means the User can read write and execute but everyone else can't. Since you aren't the user _mysql you don't have permissions. You can do two things to fix this.

  • You could start it by putting sudo in front of the command you use to start the mysqld service.

    sudo service mysqld start

  • You could set the permissions recursively to 0771. This will allow the wheel (administrator) group to write to the directory.

share|improve this answer
    
I'm am already running the command mysqld_safe as root. Permissions set to 0771, I ran the command again; still the same error code, reverted permissions back. –  James Barnhill Nov 24 '11 at 15:12
add comment

Its not because you start mysql as root that its actuality started as that user. Check /etc/my.cnf and compare whether the owner of the mysql data dir is the same as specified by the parameter user=mysql_owner.

If its for example "mysql", then root switches to that user (behind the scenes) before starting mysql

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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