解决ERROR 1030 (HY000): Got error 168 from storage engine apparmor

建表时指定另外一个目录,结果出错:

mysql>  create table t1 (id int primary key,n varchar(10)) data directory='/home/mysql/data';
ERROR 1030 (HY000): Got error 168 from storage engine

在error log中有这样的提示:

2020-01-16T02:29:45.360317Z 2 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2020-01-16T02:29:45.360400Z 2 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.

以为是mysqld的权限不对,改了也没有用:

mysql> system sudo -u mysql touch  /home/mysql/data/a
mysql>  create table t1 (id int primary key,n varchar(10)) data directory='/home/mysql/data';
ERROR 1030 (HY000): Got error 168 from storage engine

到处搜索,发现是apparmor惹得祸,

# aa-status| grep mysql
   /usr/sbin/mysqld
   /usr/sbin/mysqld (15007) 

修改配置文件把相应的目录加上即可: /etc/apparmor.d/usr.sbin.mysqld

或者disable mysqld的

sudo ln -s /etc/apparmor.d/usr.sbin.mysqld  /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld 
Skipping profile in /etc/apparmor.d/disable: usr.sbin.mysqld
姚远ACE CSDN认证博客专家 ACE 华为云 MVP
Oracle ACE,华为云 MVP,Oracle10g,12c OCM; MySQL 5.6,5.7,8.0 OCP;CCNA; EMC Certified; IBM P Certified; RHCE; SQLServer 764; DB2 Certified; TOEIC 890;获得过两次国家部级科技进步奖;发明过两项计算机专利。微信:yaoyuanace 邮箱:yaoyuanace(at)qq.com
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页