Magento Installation: Database connection error

November 28th, 2013 by in Backend, Bugs, Database, Magento 7
magento_db_connection_error

If you are trying to install older versions of Magento on MySQL 5.6.x you are most likely getting either “Database connection error” or “Database server does not support the InnoDB storage engine.” (depends on the version of Magento). This short post is about why this is happening and how you can fix it.

 

The error is happening because MySQL system variable “have_innodb” has been deprecated in version 5.6.1. Here’s the link to the official documentation: http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_have_innodb.

 

If you take a look at /app/code/core/Mage/Install/Model/Installer/Db.php you will notice that there is an “if” statement to check if your system has InnoDB engine supported. For example, in Magento CE 1.5.0.1 it looks like this:

 

            // check InnoDB support
            if (!isset($variables['have_innodb']) || $variables['have_innodb'] != 'YES') {
                Mage::throwException(Mage::helper('install')->__('Database server does not support the InnoDB storage engine.'));

 

…and in Magento 1.7.0.2 it’s something like this:

 

            // check InnoDB support
            if (!$resource->supportEngine()) {
                Mage::throwException(
                    Mage::helper('install')->__('Database server does not support the InnoDB storage engine.')
                );
            }

 

To resolve the issue, you can comment out this “if” statement and proceed with installation. Once the installation is complete revert the changes you have made to the file. (Besause there is a special place in hell for those who modify Magento’s core files. :) )

 

Update

If you still have issues, try the following. Open app/code/core/Mage/Install/etc/config.xml and search for line

<pdo_mysql/>

. Replace the line with

<pdo_mysql>1</pdo_mysql>

then save the file and run the installation. After the installation is completed, revert the file to its original state. Of course, make sure first that you have pdo and mysql enabled in your php.ini.

Written by Nikola Stojiljkovic

Nikola is a Certified Magento Backend Developer with a passion for high quality code that follows standards and best practices. He also leads our Magento development teams so you can expect excellent Magento articles from him.


See all articles from this author »

Comment (7)

Posted on August 10, 2014 by Choinek

I'm leaving comment here just to tell you "+1, thanks for fast solution". With my comment you can be sure that this post has helped at least one person. [No one else answered!]

Posted on August 16, 2014 by Nikola Stojiljkovic

Thank you :) I can see in Google Analytics that this page has decent amount of visitors. They just don't seem to talk much :)

Posted on September 29, 2014 by p. sudhakar reddy

Hi When i try to fresh installation of Meganto 1.9...i am getting a database error and though i am entering currect database name, user id, password..still it is giving a problem ..pls help how to solve this problem

Posted on October 22, 2014 by Mir

i am using magento 1.7.0.2,php 5.3, mysql 5.0.77 .i commented above codes in installation time , but still sucking with "Database Connection error". Please help it seem that you have already crossed this hurdle .

Posted on October 31, 2014 by Mike

I've got the same problem Mir... paste the cose still got the problem... how is there a way around this?? It's starting to frustrate now. :(

Posted on October 31, 2014 by Mike

Cose = code sorry...

Posted on November 30, 2014 by Nikola Stojiljkovic

Sorry for the late reply. If you still have issues with database connectivity during installation, try editing the "app/code/core/Mage/Install/etc/config.xml" file by changing the line <pdo_mysql/> to <pdo_mysql>1</pdo_mysql>. Of course, revert the changes when you complete the installation, as with all other Magento core files.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>