问题说明  

  今天部署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. java.awt.AWTError: Can't connect to X11 window server using ':20' as the value of the DISPLAY variable

    1.使用pio在Linux服务器上创建window文件时,需要使用到Linux的图形界面服务,出现以下问题需确认用户权限. 参考文献:https://zhidao.baidu.com/question ...

  2. Chrome Extensions API & options

    Chrome Extensions API options https://developer.chrome.com/extensions https://developer.chrome.com/e ...

  3. [AHOI2009]最小割 最小割可行边&必须边

    ~~~题面~~~ 题解: 做这题的时候才知道有最小割可行边和必须边这种东西..... 1,最小割可行边, 意思就是最小割中可能出现的边. 充要条件: 1,满流 2,在残余网络中找不到x ---> ...

  4. FPGA学习记录_设计一个计数器

    此处设计一个数器,使 学习板上 的 LED 状态每 500ms翻转一次. 学习板上晶振为50MHz,也就是说时钟周期为 20ns , 这样可以计算得出 500ms = 500_000_000ns/20 ...

  5. Educational Codeforces Round 39 (Rated for Div. 2) G

    Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 < ...

  6. uboot主Makefile分析(t配置和编译过程详解)

    1.编译uboot前需要三次make make distcleanmake x210_sd_configmake -j4 make distclean为清楚dist文件. make x210_sd_c ...

  7. iPhoneX页面安全区域与内容重叠问题

    转载自:https://www.cnblogs.com/lolDragon/p/7795174.html 1.  iPhoneX的介绍 屏幕尺寸 我们熟知的iPhone系列开发尺寸概要如下: △ iP ...

  8. Redis(3) 配置文件 redis.conf

    Redis.conf 配置详解: # Redis configuration file example. # # Note that in order to read the configuratio ...

  9. 常见一个新的maven web工程

    使用Eclipse创建一个新的maven Web应用工程,步骤如下: 1.在Elipse中新建一个maven工程,点击next: 2.选择工程路径(此处使用默认的),点击next: 3.选择Arche ...

  10. Debug模式下加载文件,运行程序异常的慢

    今天在进行单元测试的时候,debug模式下加载速度很慢,但是run模式下速度很快. 原因:在debug模式下,断点位置不当,解决办法 移除编译器中的所有断点.