I run a centos7 server with Cpanel. PHP Version 7.2.26
Im trying to connect to CDbConnection. All i get is error:
Fatal error: Uncaught CDbException: CDbConnection failed to open the DB connection. in yiiframework/db/CDbConnection.php:405 Stack trace:
#0 /yiiframework/db/CDbConnection.php(347): CDbConnection->open()
#1 /yiiframework/db/CDbConnection.php(325): CDbConnection->setActive(true)
#2 /yiiframework/base/CModule.php(394): CDbConnection->init()
#3 /yiiframework/base/CModule.php(103): CModule->getComponent('db')
#4 /protected/components/FunctionsV3.php(6210): CModule->__get('db')
#5 /protected/controllers/StoreController.php(149): FunctionsV3::checkIfTableExist('option')
#6 /yiiframework/web/CWebApplication.php(281): StoreController->init()
#7 /yiiframework/web/CWebApplication.php(141): CWebApplication->runController('store/index')
#8 /yiiframework/base/CApplication.php(185): CWebApplication- in /yiiframework/db/CDbConnection.php on line 405
I have tryed everything, the settings is ok. This is my db connect
'db'=>array(
'class' => 'CDbConnection',
'connectionString' => 'mysql:host=xxxxxxxxxxxxx;port=3306;dbname=xxxxxxxxx',
'emulatePrepare' => true,
'username' => 'xxxxxxxxxx',
'password' => 'xxxxxxxxxxxxxxxxxx',
'charset' => 'utf8',
'tablePrefix' => 'mt_',
),
db.php. Check here -> yiiframework.com/doc/guide/2.0/en/… . Also if you use CPanel, there should be an option pane for PHP settings -> manage.accuwebhosting.com/knowledgebase/2331/…. Make sure you have yourpdo_mysqlenabled, hence it won't work.