3

I moved my website from old hosting to new hosting and its giving me error every were like following

please any one sort this out

There has been an error processing your request
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'

Trace:
#0 C:\inetpub\vhosts\dotnpixel.uk\intu.online\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Zend\Db\Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 C:\inetpub\vhosts\dotnpixel.uk\intu.online\lib\Zend\Db\Adapter\Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 C:\inetpub\vhosts\dotnpixel.uk\intu.online\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ad...', Array)
#4 C:\inetpub\vhosts\dotnpixel.uk\intu.online\lib\Varien\Db\Adapter\Pdo\Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ad...', Array)
#5 C:\inetpub\vhosts\dotnpixel.uk\intu.online\lib\Zend\Db\Adapter\Abstract.php(576): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ad...', Array)
#6 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\AdminNotification\Model\Resource\Inbox.php(120): Zend_Db_Adapter_Abstract->insert('adminnotificati...', Array)
#7 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\AdminNotification\Model\Inbox.php(118): Mage_AdminNotification_Model_Resource_Inbox->parse(Object(Mage_AdminNotification_Model_Inbox), Array)
#8 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\AdminNotification\Model\Feed.php(97): Mage_AdminNotification_Model_Inbox->parse(Array)
#9 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\AdminNotification\Model\Observer.php(50): Mage_AdminNotification_Model_Feed->checkUpdate()
#10 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\Core\Model\App.php(1338): Mage_AdminNotification_Model_Observer->preDispatch(Object(Varien_Event_Observer))
#11 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\Core\Model\App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Mage_AdminNotification_Model_Observer), 'preDispatch', Object(Varien_Event_Observer))
#12 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\Mage.php(448): Mage_Core_Model_App->dispatchEvent('controller_acti...', Array)
#13 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\Core\Controller\Varien\Action.php(527): Mage::dispatchEvent('controller_acti...', Array)
#14 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\Adminhtml\Controller\Action.php(160): Mage_Core_Controller_Varien_Action->preDispatch()
#15 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\Core\Controller\Varien\Action.php(407): Mage_Adminhtml_Controller_Action->preDispatch()
#16 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#17 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\Core\Controller\Varien\Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#18 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#19 C:\inetpub\vhosts\dotnpixel.uk\intu.online\app\Mage.php(684): Mage_Core_Model_App->run(Array)
#20 C:\inetpub\vhosts\dotnpixel.uk\intu.online\index.php(90): Mage::run('', 'store')
#21 {main}
3

No clue why this happens, but I can tell you what happens and a guess what the problem is:

Magento is checking all registered RSS feeds for admin news (the annoying bar at the top XXX unread notifications ALERT!! NEW PATCH bla foo).

When magento checks the feeds, all new items are written to the adminnoticiation_inbox table.

When this happens the primary_key is not set, so I would assume:

While copying the database you dropped the AUTOINCREMENT

2

I agree with Fabian's answer in that I would assume that your table lost it's last increment id. On that table, back it up, then either set the increment id to a number higher than your largest id, or clear out the values in that table.

ALTER TABLE adminnotification_inbox AUTO_INCREMENT=X;  

(set X to a number higher than your largest notification_id)

1

You should run Magento's database checking tool.

I don't know how this happens, but I have seen Magento installations where many or all of the foreign key restraints are missing. In your case, the auto increment setting seems to be turned off for that table, but you might have other errors too. Do you know which method was used to backup the DB on the original server?

mysqldump saves all key constraints correctly by default. But if someone inexperienced used the phpMyAdmin database backup function, I think they could have easily messed this up.

The error says you have a duplicate key "0". There should never be primary key auto-increment value of 0. They start at 1. So I think one record was already added to your table on the new server with ID "0". Now the second attempt is failing.

As a quick fix ( backup your database first):

  1. Find the max value of your primary key.
  2. Change the "0" value to be the max value +1.
  3. Add back the autoincrement setting for your primary key.

I'll use "table" for your table name and "id" as your primary key. Replace with your own values.

# 1
SELECT MAX(`id`) FROM `table`; # suppose your result is "55";

# 2
UPDATE `table` SET `id` = 56 WHERE `id` = 0; # Now, no more id of "0";

# 3
ALTER TABLE `table` CHANGE `id` `id` INT( 11 ) NOT NULL AUTO_INCREMENT;
# assuming datatype(length) would likely be INT(11)
1

this error occurs when database user has a access problem. if you give full access (full permission) to db user then your problem is solve.

0
0

do auto increment for the primary key and you'll be fine.

(Thorough Mysql Workbench) right-click on table-->alter-table-->check the auto increment on PK

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.