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

How to move mysql5.7.19 data storage location in Centos7

Scenario: As the amount of data increases, the di...

A brief discussion on the implementation principle of Vue slot

Table of contents 1. Sample code 2. See the essen...

Set the width of the table to be fixed so that it does not change with the text

After setting the table width in the page to width...

How to compile and install xdebug in Ubuntu environment

This article describes how to compile and install...

Docker implements container port binding local port

Today, I encountered a small problem that after s...

Introducing the code checking tool stylelint to share practical experience

Table of contents Preface text 1. Install styleli...

mysql server is running with the --skip-grant-tables option

The MySQL server is running with the --skip-grant...

How to use Vue-router routing

Table of contents 1. Description 2. Installation ...

JavaScript to achieve digital clock effects

This article example shares the specific code for...

Three ways to copy MySQL tables (summary)

Copy table structure and its data The following s...

Solution to MySQL master-slave delay problem

Today we will look at why master-slave delay occu...

A simple method to modify the size of Nginx uploaded files

Original link: https://vien.tech/article/138 Pref...