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

CSS to achieve Cyberpunk 2077 style visual effects in a few steps

background Before starting the article, let’s bri...

Example code of how to implement pivot table in MySQL/MariaDB

The previous article introduced several methods f...

MySQL 8.X installation tutorial under Windows

I had been using MySQL 5.7 before, but because My...

MySQL 5.7.31 64-bit free installation version tutorial diagram

1. Download Download address: https://dev.mysql.c...

WeChat applet date and time component (year, month, day, hour, and minute)

This article example shares the specific code of ...

js to realize the mouse following game

This article shares the specific code of js to im...

React implements double slider cross sliding

This article shares the specific code for React t...

Explore the truth behind the reload process in Nginx

Today's article mainly introduces the reload ...

4 functions implemented by the transform attribute in CSS3

In CSS3, the transform function can be used to im...

Vue implements a simple calculator

This article example shares the specific code of ...

Centos8 (minimum installation) tutorial on how to install Python3.8+pip

After minimizing the installation of Python8, I i...

How to make vue long list load quickly

Table of contents background Main content 1. Comp...

Details of MutationObServer monitoring DOM elements in JavaScript

1. Basic Use It can be instantiated through the M...

How to check and organize website files using Dreamweaver8

What is the purpose of creating your own website u...

Reasons why MySQL 8.0 statistics are inaccurate

Preface Whether it is Oracle or MySQL, the new fe...