symfony: Running `php app/console` strange database error
I have a Symfony2 application (2.6.x-dev, problem only occurs on 2.6.x) and I am running into some strange problems. If I delete the database that my application connects to and the run the following:
php app/console
It should display only a list of the commands I could run, but instead, it will throw the following error:
[PDOException]
SQLSTATE[HY000] [1049] Unknown database 'mango_db'
Why is this happening? This way I can’t run the php app/console doctrine:database:create command, because it throws this exception.
If I switch to Symfony 2.5.x-dev, the problem goes away and I can run php app/console.
Here a detailed stacktrace when I access it through the browser (maybe some helpful information).
PDOException in PDOConnection.php line 40:
SQLSTATE[HY000] [1049] Unknown database 'mango_db'
in PDOConnection.php line 40
at PDO->__construct('mysql:host=127.0.0.1;dbname=mango_db;charset=UTF8;', 'root', null, array()) in PDOConnection.php line 40
at PDOConnection->__construct('mysql:host=127.0.0.1;dbname=mango_db;charset=UTF8;', 'root', null, array()) in Driver.php line 41
at Driver->connect(array('driver' => 'pdo_mysql', 'host' => '127.0.0.1', 'port' => null, 'dbname' => 'mango_db', 'user' => 'root', 'password' => null, 'charset' => 'UTF8', 'driverOptions' => array()), 'root', null, array()) in Connection.php line 356
at Connection->connect() in Connection.php line 680
at Connection->executeQuery('SELECT s0_.namespace AS namespace0, s0_.name AS name1, s0_.value AS value2, s0_.id AS id3 FROM sylius_settings_parameter s0_ WHERE s0_.namespace = ?', array('general'), array('2'), null) in SingleSelectExecutor.php line 50
at SingleSelectExecutor->execute(object(Connection), array('general'), array('2')) in Query.php line 286
at Query->_doExecute() in AbstractQuery.php line 794
at AbstractQuery->execute(null, '1') in AbstractQuery.php line 574
at AbstractQuery->getResult() in EntityRepository.php line 106
at EntityRepository->findBy(array('namespace' => 'general')) in SettingsManager.php line 190
at SettingsManager->getParameters('general') in SettingsManager.php line 103
at SettingsManager->loadSettings('general') in CurrencyContext.php line 41
at CurrencyContext->getDefaultCurrency() in CurrencyContext.php line 36
at CurrencyContext->__construct(object(Session), object(SecurityContext), object(SettingsManager), object(EntityManager)) in appDevDebugProjectContainer.php line 10918
at appDevDebugProjectContainer->getSylius_Context_CurrencyService() in bootstrap.php.cache line 2077
at Container->get('sylius.context.currency') in appDevDebugProjectContainer.php line 16331
at appDevDebugProjectContainer->getSylius_Templating_Helper_MoneyService() in bootstrap.php.cache line 2077
at Container->get('sylius.templating.helper.money') in appDevDebugProjectContainer.php line 18621
at appDevDebugProjectContainer->getTwigService() in bootstrap.php.cache line 2077
at Container->get('twig') in appDevDebugProjectContainer.php line 16526
at appDevDebugProjectContainer->getTemplatingService() in bootstrap.php.cache line 2077
at Container->get('templating') in appDevDebugProjectContainer.php line 9097
at appDevDebugProjectContainer->getNelmioApiDoc_Formatter_HtmlFormatterService() in bootstrap.php.cache line 2077
at Container->get('nelmio_api_doc.formatter.html_formatter') in appDevDebugProjectContainer.php line 9046
at appDevDebugProjectContainer->getNelmioApiDoc_EventListener_RequestService() in bootstrap.php.cache line 2077
at Container->get('nelmio_api_doc.event_listener.request') in classes.php line 4468
at ContainerAwareEventDispatcher->lazyLoad('kernel.request') in classes.php line 4436
at ContainerAwareEventDispatcher->getListeners('kernel.request') in TraceableEventDispatcher.php line 215
at TraceableEventDispatcher->preProcess('kernel.request') in TraceableEventDispatcher.php line 107
at TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in bootstrap.php.cache line 2986
at HttpKernel->handleRaw(object(Request), '1') in bootstrap.php.cache line 2959
at HttpKernel->handle(object(Request), '1', true) in bootstrap.php.cache line 3108
at ContainerAwareHttpKernel->handle(object(Request), '1', true) in bootstrap.php.cache line 2353
at Kernel->handle(object(Request)) in app_dev.php line 31
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 21 (10 by maintainers)
Commits related to this issue
- [FrameworkBundle] enable ErrorHandler in prod — committed to symfony/symfony by nicolas-grekas 10 years ago
- bug #12285 Various fixes (nicolas-grekas) This PR was merged into the 2.6-dev branch. Discussion ---------- Various fixes | Q | A | ------------- | --- | Bug fix? | yes | New feat... — committed to symfony/symfony by fabpot 10 years ago
- Attempt to fix issue through configuration - see https://github.com/symfony/symfony/issues/12278 - see https://github.com/doctrine/DoctrineBundle/issues/351 - see http://www.doctrine-project.org/jira... — committed to OpenConext/Stepup-Middleware by deleted user 9 years ago
- Attempt to fix issue through configuration - see https://github.com/symfony/symfony/issues/12278 - see https://github.com/doctrine/DoctrineBundle/issues/351 - see http://www.doctrine-project.org/jira... — committed to OpenConext/Stepup-Middleware by deleted user 9 years ago
- Fixed access denied database error when executiong console commands - see https://github.com/symfony/symfony/issues/12278 - see https://github.com/doctrine/DoctrineBundle/issues/351 - see http://www.d... — committed to AltCtrlSupr/ACSPanel-Standard by deleted user 9 years ago
Looks like a configuration issue. You should check if you connection information is set properly in config.yml/parameters.yml.
@MadmanMonty Or just add the
server_versionto your configuration