Found solution for Magento – “SQLSTATE[HY000]: General error” on installation

Share

I wrote already in the past about eCommerce System. I play with Magento till now from time to time. Unfortunately I had some problems with the installation and I could not find  help in the web. Therefore maybe this post  can be useful for some of you how is dealing whis Magento too.

The Problem

Every time on  the installation of Magento i saw following  exception.

Error in file: ".... app/code/core/Mage/Core/sql/core_setup/mysql4-install-0.8.0.php" - SQLSTATE[HY000]: General error: 1005 Can't create table './db203484_1/#sql-1dd4_17baf.frm' (errno: 121)
Trace:
#0 .../app/code/core/Mage/Core/Model/Resource/Setup.php(286): Mage::exception('Mage_Core', 'Error in file: ...')
#1 ...app/code/core/Mage/Core/Model/Resource/Setup.php(166): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '0.8.11')
#2 .../app/code/core/Mage/Core/Model/Resource/Setup.php(154): Mage_Core_Model_Resource_Setup->_installResourceDb('0.8.11')
#3 .../app/code/core/Mage/Core/Model/Resource/Setup.php(120): Mage_Core_Model_Resource_Setup->applyUpdates()
#4 .../app/code/core/Mage/Core/Model/Config.php(215): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 .../app/code/core/Mage/Core/Model/App.php(236): Mage_Core_Model_Config->init(Array)
#6 .../app/Mage.php(424): Mage_Core_Model_App->init('', 'store', Array)
#7 .../app/Mage.php(443): Mage::app('', 'store', Array)
#8 .../index.php(52): Mage::run()
#9 {main}

I tried installation with version 1.1.3, 1.1.4, 1.1.6 and 1.1.8 nothing helped…

You can find many threads on Magentocommere Forum to this issue. Some hints may help you once but do not solve the problem. I guess I don’t have solved problem globally. But I found the cause of the problem so everybody can solve it on his own way.

Cause of the exception

During the installation routine  many DB-Tables should be created in your Database. We talk here about MySQL Database.  So Magento begins with SQL-Statement that are holded in the mysql4-install-0.8.0.php.This file is also pintet in the Exception message as the causes of the problem.

I analysed the Statement and this came out..

Before any CREATE-Statement – Magento executes this:

SET SQL_MODE=''
SET @OLD_FOREIGN_KEY_CHECKS=@@
FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'

Then, after all tables and indexes  defined in  mysql4-install-0.8.0.php are created, magento executes following Statement.:

SET SQL_MODE=IFNULL(@OLD_SQL_MODE,'')
SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS,0)

An the last row causes #1231 – Variable ‘foreign_key_checks’ can’t be set to the value of ‘0’ Exception which is finely identified by me as  the cause of such installation problems!

Solution

I did’n spend much time to find out why the Varibale SET FOREIGN_KEY_CHECKS can’t be set to ’0′, because it looks like MySQL bug.

However, it’s maybe not the finest solution but it helps. If you can drop the whole the database and create new one, then the installation works. It seems to set all the before settings back and installtion works fine on “vergin-Databases”.

Leave a Reply

You must be logged in to post a comment.