我使用MySQL 5.7和CentOS 7.2。
首先,我在my.cnf中的datadir配置是/ var / lib / mysql
现在我要更改datadir。
我hava尝试两种方式:
首先,我将/ var / lib / mysql中的所有文件和目录复制到/ home / data,然后运行chown -R mysql:mysql /home/data
。但是当我运行systemctl start mysqld
时,我收到错误消息:
2016-12-08T16:33:38.206780Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2016-12-08T16:33:38.206806Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2016-12-08T16:33:38.206817Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2016-12-08T16:33:38.807398Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2016-12-08T16:33:38.807421Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-12-08T16:33:38.807429Z 0 [ERROR] Failed to initialize plugins.
2016-12-08T16:33:38.807436Z 0 [ERROR] Aborting
其次,我将/ var / lib / mysql移动到/ home并在/ var / lib目录中运行ln -s /home/mysql mysql
。当我运行systemctl start mysqld
时,收到错误消息:
2016-12-08T16:48:28.958136Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2016-12-08T16:48:28.958165Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2016-12-08T16:48:28.958174Z 0 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions
2016-12-08T16:48:28.958184Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2016-12-08T16:48:29.558751Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2016-12-08T16:48:29.558792Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-12-08T16:48:29.558806Z 0 [ERROR] Failed to initialize plugins.
2016-12-08T16:48:29.558817Z 0 [ERROR] Aborting
我该如何处理?
答案 0 :(得分:0)
这个问题与subdir权限有关
你应该编辑这个文件/etc/apparmor.d/local/usr.sbin.mysqld
/data/ r,
/data/** rwk,
别忘了,你应该在centos找到相同的命令,比如这个
sudo service apparmor reload
关于ubuntu sys的这个问题,请参阅链接
快乐的一天,baddy