无法在 OS X 10.8.5 上启动通过 macports 安装的 MySQL 5.6(新安装错误号:13 - 权限被拒绝)

Ste*_*sen 4 mysql mac-osx

很长一段时间以来,我一直在谷歌搜索并将我的头撞在这个上面。我之前没有在这个系统上安装 MySQL,只是通过 MacPorts 安装了 5.6 版,并sudo mysql_install_db在端口安装后运行。但是我无法启动服务器。

为了诊断问题,我尝试运行sudo -u _mysql /opt/local/lib/mysql56/bin/mysqld并获得类似的输出...

2013-10-03 21:40:13 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-10-03 21:40:13 23189 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql56/ is case insensitive
2013-10-03 21:40:13 23189 [Note] Plugin 'FEDERATED' is disabled.
/opt/local/lib/mysql56/bin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied)
...
2013-10-03 21:40:13 7fff7c8c2180  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
...
Run Code Online (Sandbox Code Playgroud)

当我跑步时sudo ls -l /opt/local/var/db/mysql56/,我看到...

-rw-r--r--   1 root    _mysql         0 Aug  4 15:00 .turd_mysql56-server
-rw-rw----   1 _mysql  _mysql        56 Oct  2 23:09 auto.cnf
-rw-rw----   1 _mysql  _mysql  50331648 Oct  3 22:50 ib_logfile0
-rw-rw----   1 _mysql  _mysql  50331648 Oct  2 23:09 ib_logfile1
-rw-rw----   1 _mysql  _mysql  12582912 Oct  3 00:10 ibdata1
drwx------  81 root    _mysql      2754 Oct  3 00:10 mysql
drwx------  55 root    _mysql      1870 Oct  3 00:10 performance_schema
drwx------   2 root    _mysql        68 Oct  3 00:09 test
Run Code Online (Sandbox Code Playgroud)

当我跑步时sudo ls -l /opt/local/var/db/mysql56/mysql,我看到...

...
-rw-rw----  1 root  _mysql    1024 Oct  3 00:09 plugin.MYI
-rw-rw----  1 root  _mysql    8586 Oct  3 00:09 plugin.frm
-rw-rw----  1 root  _mysql       0 Oct  3 00:09 proc.MYD
...
Run Code Online (Sandbox Code Playgroud)

我想这就是我应该看到的文件所有权和权限。有任何想法吗?

小智 5

以 root 身份登录并执行:

chown -R _mysql:_mysql /opt/local/var/db/mysql56
Run Code Online (Sandbox Code Playgroud)