MySQL (local) owner and permissions

17,795

MySQL by default witll run as the user specified by my.cnf, if at some point in the future you want to run mysql as your user you can change that on ´my.cnf´ by adding the following lines

user=USERNAME

Or if you want to add it as a startup option to mysqld or mysqld_safe

--user=USERNAME

Also the default permissions for directories inside the mysql data directory (this is in Linux, but it should apply to the Mac version too):

  • 755 (rwxr-xr-x) for mysql top data directory
  • 700 (rwx------) for each database directory
  • 660 (rw-rw----) for database files
Share:
17,795

Related videos on Youtube

Johanna
Author by

Johanna

Updated on September 17, 2022

Comments

  • Johanna
    Johanna almost 2 years

    I recently successfully installed the 64 bit version of mysql-5.5.8 on a MacBook Pro in the /usr/local directory.

    To address a completely unrelated software (RVM actually) , I chown-ed my /usr/local directory to $USER, Which made MySQL very unhappy. It complained specifically about the /usr/local/mysql/data directory, so I chown-ed that directory to _mysql:wheel.

    Everything appears to work again, but it made me wonder if I would have been better off changing the owner of the whole /usr/local/mysql directory, not just the data subdirectory.

    Since I neglected to make notes of what owner the default installation runs under before rashly changing the owner of the /usr/local directory, could someone tell me what owner and permissions the /usr/local/mysql directory is by default if you don't inadvertently screw it up? :-/

    In terms of permissions I'm guessing rwxr-xr-x would be appropriate (that's what the data directory currently has and it appears to be working fine), but reinforcement for that hunch would be appreciated.

    Thanks for any help.

    Steve

  • Johanna
    Johanna over 13 years
    Oh -- thank you lynxman! I couldn't find "my.conf" - closest I could find was /usr/local/mysql/include/my_config.h - is that it? That file didn't include anything I could see as defining a USER. I guess if MySQL is starting and appears to be running, for my little test environment I'm not going to fret. Permissions seemed to be what you indicated. Thank you very much for your help. Steve