部署MySQL5.7时的权限问题

本周部署MySQL5.7的时候遇到这样的问题,在初始化的时候,总是失败,并且报错:

2019-01-09T09:47:13.957685Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2019-01-09T09:47:13.957703Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2019-01-09T09:47:13.957711Z 0 [ERROR] InnoDB: os_file_get_status() failed on '/home/www/mysqldata/ibdata1'. Can't determine file permissions
2019-01-09T09:47:13.957720Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-01-09T09:47:14.658594Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-01-09T09:47:14.658611Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-01-09T09:47:14.658618Z 0 [ERROR] Failed to initialize builtin plugins.
2019-01-09T09:47:14.658623Z 0 [ERROR] Aborting

爬坑措施:

1.检查所有目录的属性、权限,发现目录属性没错,权限都是750,找出原因了。

2.最后我测试了一下,在root用户登陆的情况下,我在服务器随便一个路径下创建目录权限都是750,至此,我联想到了umask值。

3.查看系统umask值,发现umask时0027

4.找到核心问题所在了,修改系统的umask值:在/etc/bashrc下添加umask 022,之后在source /etc/bashrc;就此将umask值改为0022

5.之后正常安装mysql就ok了

总结:在安装mysql时可能遇到很多的报错,在网上搜索,有时会找不到答案,因为不同的原因导致的报错信息可能是一样的,所以,还需要自己一步步分析来解决问题。

原文地址:https://www.cnblogs.com/new-journey/p/10262581.html