关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

MySQL启动报错:InnoDB Operating system error number 13 in a file operation的解决方法

发布时间:2023-03-06 14:04:56
1491984010112764.jpg

1、启动MySQL失败

[root@localhost ~]# systemctl start mysqld

Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

2、通过查看MySQL错误日志分析,日志文件路径可通过/etc/my.cnf查看

[root@localhost ~]# tail -fn 200 /var/log/mysqld.log

2022-12-29T11:47:48.258403Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2022-12-29T11:47:48.260168Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.40) starting as process 17893 ...

2022-12-29T11:47:48.263792Z 0 [Note] InnoDB: PUNCH HOLE support available

2022-12-29T11:47:48.263822Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2022-12-29T11:47:48.263826Z 0 [Note] InnoDB: Uses event mutexes

2022-12-29T11:47:48.263829Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier

2022-12-29T11:47:48.263836Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.12

2022-12-29T11:47:48.263839Z 0 [Note] InnoDB: Using Linux native AIO

2022-12-29T11:47:48.264145Z 0 [Note] InnoDB: Number of pools: 1

2022-12-29T11:47:48.264276Z 0 [Note] InnoDB: Using CPU crc32 instructions

2022-12-29T11:47:48.266137Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M

2022-12-29T11:47:48.273450Z 0 [Note] InnoDB: Completed initialization of buffer pool

2022-12-29T11:47:48.275630Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().

2022-12-29T11:47:48.285893Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.

2022-12-29T11:47:48.285913Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.

2022-12-29T11:47:48.285919Z 0 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions

2022-12-29T11:47:48.285927Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error

2022-12-29T11:47:48.886868Z 0 [ERROR] Plugin 'InnoDB' init function returned error.

2022-12-29T11:47:48.886924Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

2022-12-29T11:47:48.922718Z 0 [ERROR] Failed to initialize builtin plugins.

2022-12-29T11:47:48.922781Z 0 [ERROR] Aborting

 

2022-12-29T11:47:48.922889Z 0 [Note] Binlog end

2022-12-29T11:47:48.923155Z 0 [Note] Shutting down plugin 'CSV'

2022-12-29T11:47:48.923820Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

翻译内容大致意思:

[错误] InnoDB:文件操作中的操作系统错误号13。

[错误] InnoDB:该错误意味着mysqld没有访问该目录的权限。

[错误] InnoDB: os_file_get_status()在上失败。/ibdata1。无法确定文件权限

[错误] InnoDB:插件初始化中止,出现错误一般错误

[错误]插件"InnoDB"初始化函数返回错误。

[错误]插件"InnoDB"注册为存储引擎失败。

[错误]初始化内置插件失败。

[错误]中止

3、解决方法

1)查看selinux状态

[root@localhost ~]# getenforce

Enforcing

[root@localhost ~]# sestatus

SELinux status:                 enabled

SELinuxfs mount:              /sys/fs/selinux

SELinux root directory:      /etc/selinux

Loaded policy name:          targeted

Current mode:                   Enforcing

Mode from config file:        disabled

Policy MLS status:            enabled

Policy deny_unknown status:   allowed

Max kernel policy version:        31

2)临时关闭selinux,重启失效

[root@localhost ~]# setenforce 0

3)永久关闭selinux,重启生效

[root@localhost ~]# cp -r /etc/selinux/config /etc/selinux/config.bak

[root@localhost ~]# sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config

4、再次启动MySQL服务,验证是否正常启动

[root@localhost ~]# systemctl start mysqld

5、查看MySQL服务状态

[root@localhost ~]# systemctl status mysqld

  • mysqld.service - MySQL Server

   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

   Active: active (running) since Thu 2022-12-29 12:17:05 UTC; 18h ago

     Docs: man:mysqld(8)

           http://dev.mysql.com/doc/refman/en/using-systemd.html

  Process: 28900 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)

  Process: 28877 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)

 Main PID: 28904 (mysqld)

   CGroup: /system.slice/mysqld.service

           └─28904 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Dec 29 12:17:02 localhost.novalocal systemd[1]: Starting MySQL Server...

Dec 29 12:17:05 localhost.novalocal systemd[1]: Started MySQL Server.



/template/Home/8a/PC/Static