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

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

我已经在 Google 上搜索了很长时间,并且为此绞尽脑汁。我之前没有在这个系统上安装过 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.
...

当我跑步时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

当我跑步时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
...

我认为这就是我应该看到的文件所有权和权限。有什么想法吗?

答案1

以root身份登录并执行:

chown -R _mysql:_mysql /opt/local/var/db/mysql56

答案2

你以用户 _mysql 的身份运行 mysql,因此 _mysql 需要具有数据库目录的权限

cd /opt/local/var/db/mysql56/mysql
chown -R _mysql mysql performance_schema test

相关内容