cannot find mysql.frm_Mysql Error: /usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 1...

# 变更Mysql存储位置导致问题

## 问题介绍

DB Server磁盘不足,挂载了一块新300G新磁盘,磁盘挂载在/u01目录。需将Mysql数据/var/lib/mysql移动到/u01/mysql/data下,并为/u01/mysql/data创建一个目录软链接指向/var/lib/mysql。在完成以上操作后重启Mysql时发生异常,无法启动Mysql,异常如下:

```

170523 2:32:00 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.

170523 2:32:00 [Warning] Using unique option prefix innodb_buffer_pool_instance instead of innodb-buffer-pool-instances is deprecated and will be removed in a future release. Please use the full name instead.

170523 2:32:00 [Note] Plugin 'FEDERATED' is disabled.

/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)

170523 2:32:00 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

170523 2:32:00 InnoDB: The InnoDB memory heap is disabled

170523 2:32:00 InnoDB: Mutexes and rw_locks use GCC atomic builtins

170523 2:32:00 InnoDB: Compressed tables use zlib 1.2.8

170523 2:32:00 InnoDB: Using Linux native AIO

170523 2:32:00 InnoDB: Initializing buffer pool, size = 2.0G

170523 2:32:00 InnoDB: Completed initialization of buffer pool

170523 2:32:00 InnoDB: Operating system error number 13 in a file operation.

InnoDB: The error means mysqld does not have the access rights to

InnoDB: the directory.

InnoDB: File name ./ibdata1

InnoDB: File operation call: 'open'.

InnoDB: Cannot continue operation.

```

## 解决方式

网上很多解决方式都是说数据文件权限不够,但其实是Mysql对数据文件有一个安全配置.

当mysql数据文件发生变更时,需要调整 `/etc/apparmor.d/usr.sbin.mysqld` 中的配置

```

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

```

改为

```

/u01/mysql/data r, /u01/mysql/data** rwk

```

执行以下命令使配置生效,再重启Mysql即可

```shell

/etc/init.d/apparmor reload

```

扫码或搜索 codercyj 关注微信公众号, 结伴学习, 一起努力

790a39566de03ac6f0352bb1b457ca38.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值