问题说明  

  今天部署MySQL,在使用mysql_install_db,初始化数据库时报如下错误

180622 11:36:38 mysqld_safe Starting mysqld daemon with databases from /data/3311/data/
2018-06-22 11:36:39 0 [Note] /usr/sbin/mysqld (mysqld 5.6.30-log) starting as process 7008 ...
2018-06-22 11:36:39 7008 [Warning] Can't create test file /data/3311/data/ip-172-31-25-230.lower-test
2018-06-22 11:36:39 7008 [Warning] Can't create test file /data/3311/data/ip-172-31-25-230.lower-test
180622 11:36:39 mysqld_safe mysqld from pid file /data/3311/run/mysqld3311.pid ended

  一直提示不能创建,验证了目录权限时没问题的,在被系统坑了几个小时之后,找到了解决的方法。

解决办法

  这个原因有二,其中任意的一个原因都会造成你被系统告知这个warning。

  第一,selinux,如果你恰好要操作的这台机器开着selinux,它确实能够使你的mysql无法在新目标位置进行mysql_install_db的操作,并爆出标题所示的警告。

  一个简单的解决办法是使用命令暂时关闭selinux,以便让你的操作可以继续下去

setenforce 0

  但最好使用一个永久方法,以便在重启后继续不要这货。

  修改/etc/selinux/config文件中设置SELINUX=disabled ,然后重启或等待下次重启。

  第二,apparmor,这个坑爹货和selinux一样的坑爹,它也对mysql所能使用的目录权限做了限制

  在 /etc/apparmor.d/usr.sbin.mysqld 这个文件中,有这两行,规定了mysql使用的数据文件路径权限

/var/lib/mysql/ r,
/var/lib/mysql/** rwk,

  你一定看到了,/var/lib/mysql/就是之前mysql安装的数据文件默认路径,apparmor控制这里mysqld可以使用的目录的权限
  我想把数据文件移动到/data/3311下,那么为了使mysqld可以使用/data/3311这个目录,照上面那两条,增加下面这两条就可以了

/data/3311/ r,
/data/3311/** rwk,

  重启apparmor

/etc/inid.d/apparmor restart

  之后,就可以顺利地干你想干的事儿了!

MySQL:Can't create test file XXX.lowe-test的更多相关文章

  1. MySQL [Warning] Can’t create test file xxx lower-test(转)

    add by zhj:修改的数据库的datadir,然后数据库就无法启动了,错误如下 2014-12-11 16:22:57 26309 [Warning] Can't create test fil ...

  2. Cocos2d-x执行时错误:Cocos2d: Get data from file(xxx.xxx) failed!

    取资源图片时遇到执行时错误: Cocos2d: Get data from file(xxx/xxx.xxx) failed! 原因是我加入资源目录的方式不正确,例如以下图,我选择的是在Resourc ...

  3. MYSQL Out of resources when opening file './xxx.MYD' (Errcode: 24)

    出现Out of resources when opening file './xxx.MYD' (Errcode: 24)错误是因为打开的文件数超过了my.cnf的--open-files-limi ...

  4. Mysql 的MYISAM引擎拷贝出现异常——Incorrect information in file 'xxx.frm'

    MYISAM引擎有三个文件 .FRM    存储表结构 .MYD    存储数据 .MYI   存储索引 当复制表时,将这三个文件同时复制到指定目录下. 异常处理: 1. Incorrect info ...

  5. Linux出现cannot create temp file for here-document: No space left on device的问题解决

    在终端输入:cd /ho 按tab键时,显示错误: bash: cannot create temp file for here-document: No space left on device 这 ...

  6. 【linux基础err】bash: cannot create temp file for here-document: No space left on device

    博主的device还有剩余空间也出现了这个问题,不知是什么原因,不过删除一些无用的内容,或者将某些有用的内容移动到其他硬盘,之后就可以正常使用了. 参考: 1. cannot create temp ...

  7. mysql 无法启动的原因Can't start server: can't create PID file: No space left on device

    一大早来到公司,看到了一个噩梦,后台总是登录不上,登录就出错,还以为被黑客入侵了.经过1个小时的排错原因如下: 我的服务器是linux的,mysql的报错日志路径是/var/log/,经过查看日志发现 ...

  8. Git error: unable to create file xxx: Filename too long

    一.问题描述 在使用 git 时,提示 error: unable to create file xxx: Filename too long error: unable to create file ...

  9. mysql无法启动,报错 Can't start server: can't create PID file: No space left on device

    然后看mysql日志文件 出现Can't start server: can't create PID file: No space left on device 这个错误. 提示磁盘空间不足 后用d ...

随机推荐

  1. Python:树的遍历

    各种遍历顺序如下图所示: 树的最大深度  # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = ...

  2. Square Root of Permutation - CF612E

    Description A permutation of length n is an array containing each integer from 1 to n exactly once. ...

  3. html的body内标签之label标签和fieldset标签

    1. <label> 标签为 input 元素定义标注(标记). label 元素不会向用户呈现任何特殊效果.不过,它为鼠标用户改进了可用性.如果您在 label 元素内点击文本,就会触发 ...

  4. [洛谷P2511][HAOI2008]木棍分割

    题目大意:有$n(n\leqslant5\times10^4)$根木棍,连续放在一起,把它们分成$m(\leqslant10^3)$段,要求使得最长的段最短,问最短的长度以及方案数 题解:要使得最长的 ...

  5. BZOJ4698 & 洛谷2463:[SDOI2008]Sandy的卡片——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=4698 https://www.luogu.org/problemnew/show/P2463#sub ...

  6. 分享几款常用的API/文档浏览器

    1.Dash 支持平台:Mac  iOS 官网:https://kapeli.com/dash 2.Zeal 支持平台:Linux Windows 官网:https://zealdocs.org/ G ...

  7. HDU 5646

    DZY Loves Partition Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Ot ...

  8. Codeforces Round #337 (Div. 2)B

    B. Vika and Squares time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. bnuoj25660 Two Famous Companies

    题目链接:https://www.bnuoj.com/v3/problem_show.php?pid=25660 这个二分真的是烧脑QAQ,想了一晚上才懂了一个大概. 首先,整体思路是二分,直观上感受 ...

  10. mybatis主键返回的实现

    向数据库中插入数据时,大多数情况都会使用自增列或者UUID做为主键.主键的值都是插入之前无法知道的,但很多情况下我们在插入数据后需要使用刚刚插入数据的主键,比如向两张关联表A.B中插入数据(A的主键是 ...