Magento 1.9 SQLSTATE[42S01] Error – How to Resolve

databasemagento-1.9MySQL

I've been having problems with my magento site. It suddenly crashed, and locked me out from even entering admin. I contacted our host to roll back our DB and nothing has changed. I even deleted the tables with the errors as suggested and cleared my local cache and /var/cache/ and still nothing. I have hundreds of products in the DB and don't want to flush them out, how can I fix this?

Error in file: "/home/sppower6/public_html/app/code/core/Mage/Admin/sql/admin_setup/install-1.6.0.0.php" - SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'admin_assert' already exists, query was: CREATE TABLE admin_assert ( assert_id int UNSIGNED NOT NULL auto_increment COMMENT 'Assert ID' , assert_type varchar(20) NULL default NULL COMMENT 'Assert Type' , assert_data text NULL COMMENT 'Assert Data' , PRIMARY KEY (assert_id) ) COMMENT='Admin Assert Table' ENGINE=INNODB charset=utf8 COLLATE=utf8_general_ci

Trace: 0 /home/sppower6/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')

1 /home/sppower6/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '1.6.1.1')

2 /home/sppower6/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb('1.6.1.1')

3 /home/sppower6/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()

4 /home/sppower6/public_html/app/code/core/Mage/Core/Model/App.php(428): Mage_Core_Model_Resource_Setup::applyAllUpdates()

5 /home/sppower6/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Model_App->_initModules()

6 /home/sppower6/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)

7 /home/sppower6/public_html/index.php(87): Mage::run('', 'store')

8 {main}

Best Answer

I think you can solve the problem by going to your server >> open file /home/sppower6/public_html/app/code/core/Mage/Admin/sql/admin_setup/install-1.6.0.0.php and comment the code to create table "admin_assert"


/**
 * Create table 'admin/assert'
 */
$table = $installer->getConnection()
    ->newTable($installer->getTable('admin/assert'))
    ->addColumn('assert_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
        'identity'  => true,
        'unsigned'  => true,
        'nullable'  => false,
        'primary'   => true,
        ), 'Assert ID')
    ->addColumn('assert_type', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
        'nullable'  => true,
        'default'   => null,
        ), 'Assert Type')
    ->addColumn('assert_data', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
        ), 'Assert Data')
    ->setComment('Admin Assert Table');
$installer->getConnection()->createTable($table);

Hope this help.

Related Topic