MySQL 未知/不支持的存储引擎:InnoDB

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33109315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:19:49  来源:igfitidea点击:

Unknown/unsupported storage engine: InnoDB

mysqlcentosselinux

提问by a coder

I'm setting up a replication server and when I try to start the mysql service for the first time, it fails:

我正在设置一个复制服务器,当我第一次尝试启动 mysql 服务时,它失败了:

[root@ravioli mysql]# service mysqld start
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]
[root@ravioli mysql]# tail /var/log/mysqld.log 
151013 13:41:27 [ERROR] Plugin 'InnoDB' init function returned error.
151013 13:41:27 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
/usr/libexec/mysqld: File '/databases/mysql/mysql_slow_queries.log' not found (Errcode: 13)
151013 13:41:27 [ERROR] Could not use /databases/mysql/mysql_slow_queries.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
151013 13:41:27 [ERROR] Unknown/unsupported storage engine: InnoDB
151013 13:41:27 [ERROR] Aborting

151013 13:41:27 [Note] /usr/libexec/mysqld: Shutdown complete

151013 13:41:27 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

I confirmed that user mysqlsees and is able to write to /databases/mysql/mysql_slow_queries.log.

我确认用户mysql看到并能够写入/databases/mysql/mysql_slow_queries.log.

Then I checked getenforceand see it is set to Enforcing.

然后我检查getenforce并看到它设置为Enforcing.

How do I configure MySQL to play nicely with SELinux?

如何配置 MySQL 以与 SELinux 完美配合?

采纳答案by a coder

Ok this was actually much easier than expected.

好吧,这实际上比预期的要容易得多

By default SELinuxis Enforcing, which prevents unexpected writes on the filesystem. I just needed to tell SELinux that it's OK for MySQL to write to a non-standard directory. To wit:

默认情况下SELinuxEnforcing,它可以防止文件系统上的意外写入。我只需要告诉 SELinux MySQL 可以写入非标准目录。以机智:

[root@ravioli]# semanage fcontext -a -t mysqld_db_t "/databases/mysql(/.*)?"
-bash: semanage: command not found.

Derp. To install semanage, use this:

德普。要安装semanage,请使用:

yum install policycoreutils-python

Now run the command again. This may take a few moments...

现在再次运行命令。这可能需要一些时间...

[root@ravioli]# semanage fcontext -a -t mysqld_db_t "/databases/mysql(/.*)?"

Check to see that SELinux is configured for this new directory by looking at this config file:

通过查看此配置文件,检查是否为这个新目录配置了 SELinux:

[root@ravioli]#  grep -i mysql /etc/selinux/targeted/contexts/files/file_contexts.local

/databases/mysql(/.*)?    system_u:object_r:mysqld_db_t:s0

Additional directories can be added, for instance if you have a dedicated tmp directory somewhere.

可以添加其他目录,例如,如果您在某处有专用的 tmp 目录。

[root@ravioli]# semanage fcontext -a -t mysqld_db_t "/databases/mysql_tmp(/.*)?"

Check the config again:

再次检查配置:

[root@ravioli]# grep -i mysql /etc/selinux/targeted/contexts/files/file_contexts.local

/databases/mysql(/.*)?    system_u:object_r:mysqld_db_t:s0
/databases/mysql_tmp(/.*)?    system_u:object_r:mysqld_db_t:s0

Finally, update the permissions using restorecron

最后,使用更新权限 restorecron

restorecon -R -v /www/databases/mysql/

and in my setup,

在我的设置中,

restorecon -R -v /www/databases/mysql_tmp/

Now issue:

现在发出:

service mysqld start

Bene.

贝恩。

Starting mysqld:         [  OK  ]

回答by Christopher Kikoti

All I needed was to delete two files which are:

我只需要删除两个文件,它们是:

ib_logfile0

and

ib_logfile1

Then going back to start mysql everything worked

然后回去启动mysql一切正常

回答by Anders B

This resolved my problem

这解决了我的问题

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoremove

sudo rm /var/lib/mysql/ib_logfile0
sudo rm /var/lib/mysql/ib_logfile1

sudo apt-get install mysql-server