mysql8 data dir owner and permissions?

Bjarne D Mathiesen macintosh at mathiesen.info
Mon Jun 21 16:15:01 UTC 2021



Bill Cole wrote:
> On 2021-06-18 at 12:40:30 UTC-0400 (Fri, 18 Jun 2021 12:40:30 -0400)
> Murray Eisenberg <murrayeisenberg at gmail.com>
> is rumored to have said:
> 
>> I have a non-default location for the data dir with mysql8, namely, as
>> specified in my.cnf:
>>
>>     datadir = /Users/me/Databases/mysql/data
>>
>> What should the ownership of that directory, and its subdirectories
>> and files, be? And with what permissions?
> 
> The owner needs to be whatever user runs the mysqld process, which
> creates, deletes, reads, and writes files there as a necessary part of
> its operation. That's probably _mysql. That user ALSO needs a path up to
> the root of the filesystem that it can traverse, i.e. that it has search
> permission for. Assuming this 'me' is the same as that for your httpd
> issue, you already have that for /Users and /Users/me.
> 
> No other user needs any access except for whatever is doing your
> backups, which need read access on files & directories and search
> (execute) on directories. That is usually going to be root, so you don't
> need to be concerned about group ownership or other permissions.
> 
>> At the moment, for reasons I do not know, I have:
>>
>>     ls -ld /Users/me/Databases/mysql/data
>>     drwxr-x--- 91 me  staff 2912 Jun 18 10:18
>> /Users/me/Databases/mysql/data

The reason is probably, that you created this directory as the 'me' user
in order to later use it for your MySQL data. MySQL is on itself unable
to modify the permissions on exiting directories -or- create the needed
ones if the permissions on the enclosing directory is too strong.

> 
> So, 'chown  -R _mysql /Users/me/Databases' should do the trick.
> 

I'd do
sudo chown -R _mysql:_mysql /Users/me/Databases/mysql/data
sudo find -type f /Users/me/Databases/mysql/data -exec 660 {} \;
sudo find -type d /Users/me/Databases/mysql/data -exec 770 {} \;
sudo chown o+x /Users /Users/me /Users/me/Databases
/Users/me/Databases/mysql

-- 
Bjarne D Mathiesen
Korsør ; Danmark ; Europa
-----------------------------------------------------------------------
denne besked er skrevet i et totalt M$-frit miljø
MacPro 2010 ; OpenCore + macOS 10.15.7 Catalina
2 x 3,46 GHz 6-Core Intel Xeon ; 256 GB 1333 MHz DDR3 ECC RDIMM
ATI Radeon RX 590 8 GB


More information about the macports-users mailing list