mysql8 data dir owner and permissions?

Bill Cole macportsusers-20171215 at billmail.scconsult.com
Fri Jun 18 18:34:17 UTC 2021


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
>
> And:
>
> [~] % ls -l /Users/me/Databases/mysql/data
>  total 709416 [partial listing]
>  -rw-r----- 1 me staff 196608 Apr 6 10:04 #ib_16384_0.dblwr
> -rw-r----- 1 me staff 8585216 Feb 4 12:45 #ib_16384_1.dblwr
> drwxr-x--- 12 me staff 384 Apr 6 10:02 #innodb_temp
> -rw-r----- 1 me staff 4982504 Oct 3 2020 mymac.local.err
> -rw-r----- 1 me staff 4 Apr 6 10:02 mymac.pid
> drwxr-x--- 23 me staff 736 Oct 3 2020 Math421Blog
> -rw-r-----@ 1 me staff 56 Oct 25 2018 auto.cnf
> -rw-r----- 1 me staff 179 Mar 7 22:47 binlog.003746
> :
> -rw-r----- 1 me staff 864 Apr 6 10:02 binlog.index
> -rw------- 1 me staff 1680 Jan 2 2020 ca-key.pem
> -rw-r--r-- 1 me staff 1112 Jan 2 2020 ca.pem
> -rw-r--r-- 1 me staff 1112 Jan 2 2020 client-cert.pem
> -rw------- 1 me staff 1676 Jan 2 2020 client-key.pem
> -rw-r----- 1 me staff 5175 Apr 5 23:15 ib_buffer_pool
> -rw-r----- 1 me staff 50331648 Apr 6 10:04 ib_logfile0
> -rw-r----- 1 me staff 50331648 Feb 5 12:55 ib_logfile1
> -rw-r----- 1 me staff 79691776 Apr 6 21:01 ibdata1
> -rw-r----- 1 me staff 12582912 Apr 6 10:02 ibtmp1
> drwxr-x--- 8 me staff 256 Feb 4 12:45 mysql
> -rw-r----- 1 me staff 46137344 Apr 6 10:02 mysql.ibd
> -rw-r----- 1 me staff 6 Feb 4 12:45 mysql_upgrade_info
> drwxr-x--- 111 me staff 3552 Feb 4 12:45 performance_schema
> drwxr-x--- 21 me staff 672 Oct 3 2020 phpmyadmin
> -rw------- 1 me staff 1680 Jan 2 2020 private_key.pem
> -rw-r--r-- 1 me staff 452 Jan 2 2020 public_key.pem
> drwxr-x--- 29 me staff 928 Oct 3 2020 sakila
> -rw-r--r-- 1 me staff 1112 Jan 2 2020 server-cert.pem
> -rw------- 1 me staff 1676 Jan 2 2020 server-key.pem
> drwxr-x--- 3 me staff 96 Oct 3 2020 sys
> -rw-r----- 1 me staff 80740352 Apr 6 10:04 undo_001
> -rw-r----- 1 me staff 29360128 Feb 5 21:01 undo_002

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

-- 
Bill Cole
bill at scconsult.com or billcole at apache.org
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Not Currently Available For Hire


More information about the macports-users mailing list