陈同学
微服务
Accelerator
About
# 变更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. <b>/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)</b> 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 ```
本文由
cyj
创作,可自由转载、引用,但需署名作者且注明文章出处。
文章标题:
Mysql Error: /usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
文章链接:
https://chenyongjun.vip/articles/13
扫码或搜索 cyjrun 关注微信公众号, 结伴学习, 一起努力