magento 1.9 错误 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'domain name.log_visitor' doesn't exist

Error with magento 1.9 - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'domain name.log_visitor' doesn't exist

处理您的请求时出错

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'domain name.log_visitor' doesn't exist
Trace:
#0 /home/cgit/public_html/mimfair.com/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/cgit/public_html/mimfair.com/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/cgit/public_html/mimfair.com/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /home/cgit/public_html/mimfair.com/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `lo...', Array)
#4 /home/cgit/public_html/mimfair.com/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `lo...', Array)
#5 /home/cgit/public_html/mimfair.com/lib/Zend/Db/Adapter/Abstract.php(576): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `lo...', Array)
#6 /home/cgit/public_html/mimfair.com/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(453): Zend_Db_Adapter_Abstract->insert('log_visitor', Array)
#7 /home/cgit/public_html/mimfair.com/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mage_Log_Model_Visitor))
#8 /home/cgit/public_html/mimfair.com/app/code/core/Mage/Log/Model/Visitor.php(168): Mage_Core_Model_Abstract->save()
#9 /home/cgit/public_html/mimfair.com/app/code/core/Mage/Core/Model/App.php(1338): Mage_Log_Model_Visitor->initByRequest(Object(Varien_Event_Observer))
#10 /home/cgit/public_html/mimfair.com/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Mage_Log_Model_Visitor), 'initByRequest', Object(Varien_Event_Observer))
#11 /home/cgit/public_html/mimfair.com/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('controller_acti...', Array)
#12 /home/cgit/public_html/mimfair.com/app/code/core/Mage/Core/Controller/Varien/Action.php(527): Mage::dispatchEvent('controller_acti...', Array)
#13 /home/cgit/public_html/mimfair.com/app/code/core/Mage/Core/Controller/Front/Action.php(64): Mage_Core_Controller_Varien_Action->preDispatch()
#14 /home/cgit/public_html/mimfair.com/app/code/core/Mage/Core/Controller/Varien/Action.php(407): Mage_Core_Controller_Front_Action->preDispatch()
#15 /home/cgit/public_html/mimfair.com/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#16 /home/cgit/public_html/mimfair.com/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#17 /home/cgit/public_html/mimfair.com/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#18 /home/cgit/public_html/mimfair.com/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#19 /home/cgit/public_html/mimfair.com/index.php(87): Mage::run('', 'store')
#20 {main}

错误日志记录号:1250936715985

问题图片: http://mimfair.com/screenshot_15.jpg

似乎您的 log_visitor table 不存在。您是否可以通过某些 mysql 客户端(例如 phpmyadmin)访问数据库?执行此 SQL 语句以创建 table:

CREATE TABLE log_visitor (
  `visitor_id` bigint(20) unsigned NOT NULL auto_increment,
  `session_id` char(64) NOT NULL default '',
  `first_visit_at` datetime default NULL,
  `last_visit_at` datetime NOT NULL default '0000-00-00 00:00:00',
  `last_url_id` bigint(20) unsigned NOT NULL default '0',
  PRIMARY KEY  (`visitor_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='System visitors log';

这应该可以解决问题

对于遇到此问题的任何其他人:

CREATE TABLE IF NOT EXISTS log_visitor_online ( visitor_id bigint(20) unsigned NOT NULL auto_increment COMMENT 'Visitor ID',
visitor_type varchar(1) NOT NULL COMMENT 'Visitor Type',
remote_addr bigint(20) NOT NULL COMMENT 'Remote Address',
first_visit_at timestamp NULL default NULL COMMENT 'First Visit Time', last_visit_at timestamp NULL default NULL COMMENT 'Last Visit Time', customer_id int(10) unsigned default NULL COMMENT 'Customer ID', last_url varchar(255) default NULL COMMENT 'Last URL', PRIMARY KEY (visitor_id), KEY IDX_LOG_VISITOR_ONLINE_VISITOR_TYPE (visitor_type), KEY IDX_LOG_VISITOR_ONLINE_FIRST_VISIT_AT_LAST_VISIT_AT (first_visit_at,last_visit_at), KEY IDX_LOG_VISITOR_ONLINE_CUSTOMER_ID (customer_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Log Visitor Online Table'

第一个答案似乎缺少 store_id 列。这是一个更新:

CREATE TABLE log_visitor (
  `visitor_id` bigint(20) unsigned NOT NULL auto_increment,
  `session_id` char(64) NOT NULL default '',
  `store_id` bigint(20) unsigned NOT NULL default '0',
  `first_visit_at` datetime default NULL,
  `last_visit_at` datetime NOT NULL default '0000-00-00 00:00:00',
  `last_url_id` bigint(20) unsigned NOT NULL default '0',
  PRIMARY KEY  (`visitor_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='System visitors log';