5

I install magento 2.1.2 on localhost. Try to open it then it gives this error.

An error has happened during application run. See exception log for details.

If i use developer mode to see the message. (To Use Developer Mode : In .htaccess file i Comment out "SetEnv MAGE_MODE developer")

Then It shows This message

exception 'PDOException' with message 'SQLSTATE[HY000] [1049] Unknown database 'magento2'' in G:\Xxamp\htdocs\magento2.1.2\vendor\magento\zendframework1\library\Zend\Db\Adapter\Pdo\Abstract.php:129 Stack trace: #0 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\zendframework1\library\Zend\Db\Adapter\Pdo\Abstract.php(129): PDO->__construct('mysql:host=loca...', 'root', '', Array) #1 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\zendframework1\library\Zend\Db\Adapter\Pdo\Mysql.php(111): Zend_Db_Adapter_Pdo_Abstract->_connect() #2 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\DB\Adapter\Pdo\Mysql.php(347): Zend_Db_Adapter_Pdo_Mysql->_connect() #3 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\zendframework1\library\Zend\Db\Adapter\Abstract.php(861): Magento\Framework\DB\Adapter\Pdo\Mysql->_connect() #4 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\zendframework1\library\Zend\Db\Adapter\Abstract.php(931): Zend_Db_Adapter_Abstract->quote('default', NULL) #5 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\DB\Adapter\Pdo\Mysql.php(1372): Zend_Db_Adapter_Abstract->quoteInto('{{fieldName}} =...', 'default', NULL, NULL) #6 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\DB\Adapter\Pdo\Mysql.php(2830): Magento\Framework\DB\Adapter\Pdo\Mysql->quoteInto('{{fieldName}} =...', 'default') #7 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\DB\Adapter\Pdo\Mysql.php(2814): Magento\Framework\DB\Adapter\Pdo\Mysql->_prepareQuotedSqlCondition('{{fieldName}} =...', 'default', 'scope') #8 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\Data\Collection\AbstractDb.php(477): Magento\Framework\DB\Adapter\Pdo\Mysql->prepareSqlCondition('scope', 'default') #9 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\Data\Collection\AbstractDb.php(408): Magento\Framework\Data\Collection\AbstractDb->_getConditionSql('scope', 'default') #10 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\Data\Collection\AbstractDb.php(390): Magento\Framework\Data\Collection\AbstractDb->_translateCondition('scope', 'default') #11 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\module-store\Model\ResourceModel\Config\Collection\Scoped.php(59): Magento\Framework\Data\Collection\AbstractDb->addFieldToFilter('scope', 'default') #12 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\Model\ResourceModel\Db\Collection\AbstractCollection.php(124): Magento\Store\Model\ResourceModel\Config\Collection\Scoped->_initSelect() #13 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\module-store\Model\ResourceModel\Config\Collection\Scoped.php(48): Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection->__construct(Object(Magento\Framework\Data\Collection\EntityFactory), Object(Magento\Framework\Logger\Monolog), Object(Magento\Framework\Data\Collection\Db\FetchStrategy\Query), Object(Magento\Framework\Event\Manager\Proxy), NULL, Object(Magento\Config\Model\ResourceModel\Config\Data)) #14 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(93): Magento\Store\Model\ResourceModel\Config\Collection\Scoped->__construct(Object(Magento\Framework\Data\Collection\EntityFactory), Object(Magento\Framework\Logger\Monolog), Object(Magento\Framework\Data\Collection\Db\FetchStrategy\Query), Object(Magento\Framework\Event\Manager\Proxy), Object(Magento\Config\Model\ResourceModel\Config\Data), 'default', NULL, NULL) #15 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\ObjectManager\Factory\Dynamic\Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\Store\M...', Array) #16 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\ObjectManager\ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\Store\M...', Array) #17 G:\Xxamp\htdocs\magento2.1.2\var\generation\Magento\Store\Model\ResourceModel\Config\Collection\ScopedFactory.php(43): Magento\Framework\ObjectManager\ObjectManager->create('\Magento\Store\...', Array) #18 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\module-store\Model\Config\Reader\DefaultReader.php(63): Magento\Store\Model\ResourceModel\Config\Collection\ScopedFactory->create(Array) #19 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Config\ScopePool.php(112): Magento\Store\Model\Config\Reader\DefaultReader->read() #20 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Config.php(45): Magento\Framework\App\Config\ScopePool->getScope('default', NULL) #21 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Config.php(58): Magento\Framework\App\Config->getValue('web/secure/use_...', 'default', NULL) #22 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\module-store\Model\HeaderProvider\Hsts.php(48): Magento\Framework\App\Config->isSetFlag('web/secure/use_...') #23 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Response\HeaderManager.php(41): Magento\Store\Model\HeaderProvider\Hsts->canApply() #24 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\Interception\Interceptor.php(123): Magento\Framework\App\Response\HeaderManager->beforeSendResponse(Object(Magento\Framework\App\Response\Http\Interceptor)) #25 G:\Xxamp\htdocs\magento2.1.2\var\generation\Magento\Framework\App\Response\Http\Interceptor.php(117): Magento\Framework\App\Response\Http\Interceptor->___callPlugins('sendResponse', Array, Array) #26 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Http.php(185): Magento\Framework\App\Response\Http\Interceptor->sendResponse() #27 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Http.php(156): Magento\Framework\App\Http->handleDeveloperMode(Object(Magento\Framework\App\Bootstrap), Object(Zend_Db_Adapter_Exception)) #28 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Bootstrap.php(263): Magento\Framework\App\Http->catchException(Object(Magento\Framework\App\Bootstrap), Object(Zend_Db_Adapter_Exception)) #29 G:\Xxamp\htdocs\magento2.1.2\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http)) #30 {main} Next exception 'Zend_Db_Adapter_Exception' with message 'SQLSTATE[HY000] [1049] Unknown database 'magento2'' in G:\Xxamp\htdocs\magento2.1.2\vendor\magento\zendframework1\library\Zend\Db\Adapter\Pdo\Abstract.php:144 Stack trace: #0 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\zendframework1\library\Zend\Db\Adapter\Pdo\Mysql.php(111): Zend_Db_Adapter_Pdo_Abstract->_connect() #1 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\DB\Adapter\Pdo\Mysql.php(347): Zend_Db_Adapter_Pdo_Mysql->_connect() #2 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\zendframework1\library\Zend\Db\Adapter\Abstract.php(861): Magento\Framework\DB\Adapter\Pdo\Mysql->_connect() #3 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\zendframework1\library\Zend\Db\Adapter\Abstract.php(931): Zend_Db_Adapter_Abstract->quote('default', NULL) #4 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\DB\Adapter\Pdo\Mysql.php(1372): Zend_Db_Adapter_Abstract->quoteInto('{{fieldName}} =...', 'default', NULL, NULL) #5 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\DB\Adapter\Pdo\Mysql.php(2830): Magento\Framework\DB\Adapter\Pdo\Mysql->quoteInto('{{fieldName}} =...', 'default') #6 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\DB\Adapter\Pdo\Mysql.php(2814): Magento\Framework\DB\Adapter\Pdo\Mysql->_prepareQuotedSqlCondition('{{fieldName}} =...', 'default', 'scope') #7 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\Data\Collection\AbstractDb.php(477): Magento\Framework\DB\Adapter\Pdo\Mysql->prepareSqlCondition('scope', 'default') #8 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\Data\Collection\AbstractDb.php(408): Magento\Framework\Data\Collection\AbstractDb->_getConditionSql('scope', 'default') #9 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\Data\Collection\AbstractDb.php(390): Magento\Framework\Data\Collection\AbstractDb->_translateCondition('scope', 'default') #10 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\module-store\Model\ResourceModel\Config\Collection\Scoped.php(59): Magento\Framework\Data\Collection\AbstractDb->addFieldToFilter('scope', 'default') #11 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\Model\ResourceModel\Db\Collection\AbstractCollection.php(124): Magento\Store\Model\ResourceModel\Config\Collection\Scoped->_initSelect() #12 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\module-store\Model\ResourceModel\Config\Collection\Scoped.php(48): Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection->__construct(Object(Magento\Framework\Data\Collection\EntityFactory), Object(Magento\Framework\Logger\Monolog), Object(Magento\Framework\Data\Collection\Db\FetchStrategy\Query), Object(Magento\Framework\Event\Manager\Proxy), NULL, Object(Magento\Config\Model\ResourceModel\Config\Data)) #13 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(93): Magento\Store\Model\ResourceModel\Config\Collection\Scoped->__construct(Object(Magento\Framework\Data\Collection\EntityFactory), Object(Magento\Framework\Logger\Monolog), Object(Magento\Framework\Data\Collection\Db\FetchStrategy\Query), Object(Magento\Framework\Event\Manager\Proxy), Object(Magento\Config\Model\ResourceModel\Config\Data), 'default', NULL, NULL) #14 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\ObjectManager\Factory\Dynamic\Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\Store\M...', Array) #15 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\ObjectManager\ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\Store\M...', Array) #16 G:\Xxamp\htdocs\magento2.1.2\var\generation\Magento\Store\Model\ResourceModel\Config\Collection\ScopedFactory.php(43): Magento\Framework\ObjectManager\ObjectManager->create('\Magento\Store\...', Array) #17 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\module-store\Model\Config\Reader\DefaultReader.php(63): Magento\Store\Model\ResourceModel\Config\Collection\ScopedFactory->create(Array) #18 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Config\ScopePool.php(112): Magento\Store\Model\Config\Reader\DefaultReader->read() #19 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Config.php(45): Magento\Framework\App\Config\ScopePool->getScope('default', NULL) #20 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Config.php(58): Magento\Framework\App\Config->getValue('web/secure/use_...', 'default', NULL) #21 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\module-store\Model\HeaderProvider\Hsts.php(48): Magento\Framework\App\Config->isSetFlag('web/secure/use_...') #22 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Response\HeaderManager.php(41): Magento\Store\Model\HeaderProvider\Hsts->canApply() #23 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\Interception\Interceptor.php(123): Magento\Framework\App\Response\HeaderManager->beforeSendResponse(Object(Magento\Framework\App\Response\Http\Interceptor)) #24 G:\Xxamp\htdocs\magento2.1.2\var\generation\Magento\Framework\App\Response\Http\Interceptor.php(117): Magento\Framework\App\Response\Http\Interceptor->___callPlugins('sendResponse', Array, Array) #25 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Http.php(185): Magento\Framework\App\Response\Http\Interceptor->sendResponse() #26 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Http.php(156): Magento\Framework\App\Http->handleDeveloperMode(Object(Magento\Framework\App\Bootstrap), Object(Zend_Db_Adapter_Exception)) #27 G:\Xxamp\htdocs\magento2.1.2\vendor\magento\framework\App\Bootstrap.php(263): Magento\Framework\App\Http->catchException(Object(Magento\Framework\App\Bootstrap), Object(Zend_Db_Adapter_Exception)) #28 G:\Xxamp\htdocs\magento2.1.2\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http)) #29 {main}

What is the Solution For this Problem .. Can anyone guide me .

2

4 Answers 4

4

Pdo is php component to connect mysql

Unknown database 'magento2'' in G:\Xxamp\htdocs\magento2.1.2\vendor\magento\zendframework1\library\Zend\Db\Adapter\Pdo\Abstract.php:129 Stack trace: #0 

It's seems like mysql connection error. Check your configuration under /app/etc/env.php

In this file, a number of key things are set, including the database connection information:

‘host’ => ‘localhost’,
‘dbname’ => ‘magento2database’,
‘username’ => ‘some-sample-username’,
‘password’ => ‘Extremely-Complicated-Password-12345’,
‘model’ => ‘mysql4’,
‘engine’ => ‘innodb’,
‘initStatements’ => ‘SET NAMES utf8;’,
‘active’ => ‘1’,

This should help.

1

In case anyone else sees this frustrating message.

The fix I found was to uninstall Magento from the directory, then reinstall, but on reinstall, the setup wizard informed me that 2 PHP extensions were missing.

I logged into WHM and use Easy Apache to add those extensions, I put the original files back and voila back in business. Its weird that the logs does not mention those extensions.

Here were the missing PHP Extensions:

PHP Extension Intl. PHP Extension Iconv.

1

This happens because there may be setup:install process running (in background).

You can kill this process and reinstall Magento by using setup:unistall and setup:install.

1

I experienced the same issue. I just once stopped MySql service and restarted it MySql service from xampp control panel. It resolved the issue in my case.

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