软件包方式安装Mysql,安装好之后,启动服务报以下错误:

Starting mysqld (via systemctl):  Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

通过日志可以看到以下错误:

cat /var/log/mysqld.log

2018-11-05T14:56:36.150707Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2018-11-05T14:56:36.150728Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2018-11-05T14:56:36.150734Z 0 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions
2018-11-05T14:56:36.150744Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2018-11-05T14:56:36.751167Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2018-11-05T14:56:36.751185Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-11-05T14:56:36.751190Z 0 [ERROR] Failed to initialize builtin plugins.
2018-11-05T14:56:36.751194Z 0 [ERROR] Aborting

解决方案:setenforce 0 

就可以了