安装Magento时提示缺少InnoDB,但实际上已经存在。

41

在安装过程中,Magento出现以下错误:

数据库服务器不支持InnoDB存储引擎。

我已经解决了Magento的所有依赖项,并使用MySQL命令行检查过SHOW ENGINES,确定有InnoDB可用(也是默认的存储引擎)。

这不是关于访问MySQL配置的问题,其他人可能在他们的安装中看到了这个问题。

注意:这是在Mac Pro上运行的(使用简单的主机DNS重写开发域名)。


你使用的是哪个版本的mysql? - Michael Benjamin
5.6.10 - 我刚刚大约20分钟前下载了它。 - Giles Williams
只是确认一下,我刚创建了以下测试表格:+---------------+--------------------------------------------------------------------------------------------------------------+ | 表格 | 创建表格 | +---------------+--------------------------------------------------------------------------------------------------------------+ | mystoragetest | CREATE TABLE mystoragetest ( tester int(1) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +---------------+----- - Giles Williams
7个回答

134

位于文件 app/code/core/Mage/Install/Model/Installer/Db/Mysql4.php 的第59行

替换为:

public function supportEngine()
{
    $variables  = $this->_getConnection()
        ->fetchPairs('SHOW VARIABLES');
    return (!isset($variables['have_innodb']) || $variables['have_innodb'] != 'YES') ? false : true;
}

使用这个:

public function supportEngine()
{
    $variables  = $this->_getConnection()
        ->fetchPairs('SHOW ENGINES');
    return (isset($variables['InnoDB']) && $variables['InnoDB'] != 'NO');
}

不错,花了最后一个小时试图弄清楚这个问题。 - Daniel West
1
编辑核心代码是个坏主意,查看下面的答案:https://dev59.com/X2Up5IYBdhLWcg3wNFar#16870033 - Greg
这个更改是在magento2的主分支中的一部分,所以我认为这不会成为一个问题!https://github.com/magento/magento2 - Dennis
非常感谢!我为此奋斗了几个小时! - Jpepper
如果这里提到的代码更新已经在Magento 1.9.2.0中修复,那么它对于Magento 1.9.2.0没有帮助,该怎么办? - Ashwani Shukla

20

或者不要进行核心修改!在安装之前,您应该轻松地覆盖 Installer-Model:

将此粘贴到app/code/local/Company/InstallBugfix/etc/config.xml中:

<?xml version="1.0"?>
<config>
    <modules>
        <Company_InstallBugfix>
            <version>0.1.0</version>
        </Company_InstallBugfix>
    </modules>
    <global>
        <models>
            <installbugfix>
                <class>Company_InstallBugfix_Model</class>
            </installbugfix>
            <install>
                <rewrite>
                    <installer_db_mysql4>Company_InstallBugfix_Model_Installer_Db_Mysql4</installer_db_mysql4>
                </rewrite>
            </install>
        </models>
    </global>
</config>

接下来在app/code/local/Company/InstallBugfix/Model/Installer/Db/Mysql4.php中:

<?php
class Company_InstallBugfix_Model_Installer_Db_Mysql4 extends Mage_Install_Model_Installer_Db_Mysql4
{
    /**
     * Check InnoDB support
     *
     * @return bool
     */
    public function supportEngine()
    {
        $supportsEngine = parent::supportEngine();
        if ($supportsEngine) {
            return true;
        }
        $variables = $this
                     ->_getConnection()
                     ->fetchPairs('SHOW ENGINES');
        return (isset($variables['InnoDB']) && $variables['InnoDB'] != 'NO');
    }
}

启用扩展。优点是,如果mysql版本较旧,则仍然可以使用旧的验证方法。


关于“不要进行核心修改”的问题,确实如此...然而,核心开发团队应该负责向后兼容。 - Edward J Beckett

5

ver 1.9.1.0 下载器

这里提供给所有使用 1.9.1.0 安装程序中捆绑的 downloader.php 的人。

如果你确定你的MySQL数据库支持InnoDB(这是后来版本的默认设置),你可以安全编辑该文件以删除检查并进行下载。

    /**
     * Check availabe InnoDB on database.
     *
     * @return Magento_Downloader_Validator
     */
    protected function _checkDbInnoDb()
    {
        if (!$this->_connection) {
            return $this;
        }
        $this->addMessage('Database server supports InnoDB storage engine');
        return $this;
    }

0

Magento CE 1.8中已修复了该Bug,因此对于CE \leq 1.7,请使用上面的代码行。


只需在 downloader.php 中的 protected function _checkDbInnoDb() 函数中仍然会引发此错误。如果您确信您的数据库支持 InnoDB,则可以安全地注释掉该检查。 - Luke

-1
public function supportEngine()
{
    $variables  = $this->_getConnection()->fetchPairs('SHOW ENGINES');
    return (isset($variables['InnoDB']) && $variables['InnoDB'] != 'NO');
}

-1

我遇到了同样的问题,唯一让它起作用的方法是我更改了文件 app/code/core/Mage/Install/Model/Installer/Db/Mysql4.php 的第59行:

public function supportEngine()
{
    $variables  = $this->_getConnection()
        ->fetchPairs('SHOW VARIABLES');
    return (!isset($variables['have_innodb']) || $variables['have_innodb'] != 'YES') ? false : true;
}

使用:

public function supportEngine()
    {
        $variables  = $this->_getConnection()
            ->fetchPairs('SHOW ENGINES');
        return (isset($variables['InnoDB']) && $variables['InnoDB'] != 'YES');
    }

我在任何地方都没有找到它,所以如果你正在苦苦挣扎,我保证这将解决问题。


-2

文件 app/code/core/Mage/Install/Model/Installer/Db/Mysql4.php 的第59行

替换为:

public function supportEngine()
 {
    $variables  = $this->_getConnection()
        ->fetchPairs('SHOW VARIABLES');
    return (!isset($variables['have_innodb']) || $variables['have_innodb'] != 'YES') ? false : true;
}    

使用这个:

public function supportEngine()
{
 /*   
     $variables  = $this->_getConnection()
        ->fetchPairs('SHOW ENGINES');
     return (!isset($variables['have_innodb']) || $variables['have_innodb'] != 'YES') ? false : true; 
*/
    return 1;
}

1
你既然之后要返回“true”,为什么还费心修改fecthPairs这一行呢? - OSdave
这个主意不好,甚至可能很危险。你建议我们假装InnoDB总是启用的,而不是实际检查。 - Doug McLean

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接