MySQL reports an error: Can't find file: './mysql/plugin.frm' solution

MySQL reports an error: Can't find file: './mysql/plugin.frm' solution

Find the problem

Recently, I found a problem at work. The problem was that the MySQL disk was full. I moved the database directory data to the /data3 directory, modified the corresponding datadir directory in /etc/my.cnf, and granted permissions. However, an error occurred when service mysql start; I won’t say much below. Let’s take a look at the detailed solution.

The error log shows the following:

2017-09-15 16:01:01 2420 [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.
2017-09-15 16:01:01 2420 [Note] Plugin 'FEDERATED' is disabled.
^G/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied)
2017-09-15 16:01:01 2420 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2017-09-15 16:01:01 2420 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-09-15 16:01:01 2420 [Note] InnoDB: The InnoDB memory heap is disabled
2017-09-15 16:01:01 2420 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-09-15 16:01:01 2420 [Note] InnoDB: Memory barrier is not used
2017-09-15 16:01:01 2420 [Note] InnoDB: Compressed tables use zlib 1.2.8
2017-09-15 16:01:01 2420 [Note] InnoDB: Using Linux native AIO
2017-09-15 16:01:01 2420 [Note] InnoDB: Using CPU crc32 instructions
2017-09-15 16:01:01 2420 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-09-15 16:01:02 2420 [Note] InnoDB: Completed initialization of buffer pool
2017-09-15 16:01:02 2420 [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode
2017-09-15 16:01:02 2420 [ERROR] InnoDB: The system tablespace must be writable!
2017-09-15 16:01:02 2420 [ERROR] Plugin 'InnoDB' init function returned error.
2017-09-15 16:01:02 2420 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-09-15 16:01:02 2420 [ERROR] Unknown/unsupported storage engine: InnoDB
2017-09-15 16:01:02 2420 [ERROR] Aborting

First check the plugin.frm permissions. frm is the MySQL table structure definition file. Usually, the frm file will not be damaged. However, if the frm file is damaged under special circumstances, do not give up hope. When repairing MyISAM and InnoDB tables, the MySQL service will first call the frm file, so we can only perform subsequent data recovery by repairing the frm file.

Then we found that plugin.frm has permissions and is also the owner of mysql:

root@hutaojie-1-pdd-sh:/data1/mysql/mysql# ll plugin.*
-rwxrwxrwx 1 mysql mysql 8586 Mar 6 2016 plugin.frm*
-rwxrwx--x 1 mysql mysql 116 Mar 6 2016 plugin.MYD*
-rwxrwx--x 1 mysql mysql 2048 Mar 6 2016 plugin.MYI*
root@hutaojie-1-pdd-sh:/data1/mysql/mysql#

After searching on Google, I found that the problem was with the OS. When installing Ubuntu's MySQL via yum or rpm, a /etc/apparmor.d/usr.sbin.mysqld file will be created. If the data directory is not in it, an error will be reported.

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

Workaround

So the solution is to add a new datadir directory in it.

root@huayuan:/var/lib# vim /etc/apparmor.d/usr.sbin.mysqld 

# vim:syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include <tunables/global>

/usr/sbin/mysqld {
 #include <abstractions/base>
 #include <abstractions/nameservice>
 #include <abstractions/user-tmp>
 #include <abstractions/mysql>
 #include <abstractions/winbind>

 capability dac_override,
 capability sys_resource,
 capability setgid,
 capability setuid,

 network tcp,

 /run/mysqld/mysqld.pid rw,
 /run/mysqld/mysqld.sock w,

 /sys/devices/system/cpu/ r,
 #.........Write the new datadir directory here, write 2 lines, one line of r, and one line of rwk.
 /data3/mysql/ r,
 /data3/mysql/** rwk,
 # Site-specific additions and overrides. See local/README for details.
 #include <local/usr.sbin.mysqld>
}

Then restart the mysql instance, ok, the problem is solved.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • Solution to MySql error "Table mysql.plugin doesn't exist"
  • The perfect solution for mysql automatic stop plugin FEDERATED is disabled
  • Solution to the problem "Table mysql.plugin doesn't exist" when deploying MySQL

<<:  Three ways to check whether a port is open in a remote Linux system

>>:  JavaScript implements page scrolling animation

Recommend

nginx+tomcat example of accessing the project through the domain name

I was curious about how to access the project usi...

How to set npm to load packages from multiple package sources at the same time

Table of contents 1. Build local storage 2. Creat...

Solution to the problem of data loss when using Replace operation in MySQL

Preface The company's developers used the rep...

react-diagram serialization Json interpretation case analysis

The goal of this document is to explain the Json ...

MySQL 5.5.27 installation graphic tutorial

1. Installation of MYSQL 1. Open the downloaded M...

Analysis of the process of building a LAN server based on http.server

I don’t know if you have ever encountered such a ...

Vue+Echart bar chart realizes epidemic data statistics

Table of contents 1. First install echarts in the...

NULL and Empty String in Mysql

I recently came into contact with MySQL. Yesterda...

JavaScript simulation calculator

This article shares the specific code of JavaScri...

IE8 uses multi-compatibility mode to display web pages normally

IE8 will have multiple compatibility modes . IE pl...

The use of setState in React and the use of synchronous and asynchronous

In react, if you modify the state directly using ...

MySQL full-text search usage examples

Table of contents 1. Environmental Preparation 2....