Yii Framework Forum: Cdbconnection Failed To Open Db Connection : Could Not Find Driver - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cdbconnection Failed To Open Db Connection : Could Not Find Driver Rate Topic: -----

#1 User is offline   Samrat Kar 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 11-June 12
  • Location:Mumbai

Posted 28 June 2013 - 07:26 AM

Following is the complete error output...



CDbException

CDbConnection failed to open the DB connection: could not find driver

/var/www/eesystem/protected/components/Controller.php(23)

11      */
12     public $layout='//layouts/column1';
13     /**
14      * @var array context menu items. This property will be assigned to {@link CMenu::items}.
15      */
16     public $menu=array();
17     /**
18      * @var array the breadcrumbs of the current page. The value of this property will
19      * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
20      * for more details on how to specify this property.
21      */
22         public function init() {
23             if(Yii::app()->user->isGuest) {
24                 echo "JJJ";
25                 //Yii::app()->user->loginRequired();
26             }
27         }
28     public $breadcrumbs=array();
29 }

Stack Trace
#0 	
+
 /var/www/yii-1.1.13/framework/db/CDbConnection.php(330): CDbConnection->open()
#1 	
+
 /var/www/yii-1.1.13/framework/web/CDbHttpSession.php(185): CDbConnection->setActive(true)
#2 	
 unknown(0): CDbHttpSession->openSession("/var/lib/php5", "PHPSESSID")
#3 	
+
 /var/www/yii-1.1.13/framework/web/CHttpSession.php(118): session_start()
#4 	
+
 /var/www/yii-1.1.13/framework/web/CHttpSession.php(92): CHttpSession->open()
#5 	
+
 /var/www/yii-1.1.13/framework/base/CModule.php(387): CHttpSession->init()
#6 	
+
 /var/www/yii-1.1.13/framework/web/CWebApplication.php(201): CModule->getComponent("session")
#7 	
+
 /var/www/yii-1.1.13/framework/web/auth/CWebUser.php(193): CWebApplication->getSession()
#8 	
+
 /var/www/yii-1.1.13/framework/base/CModule.php(387): CWebUser->init()
#9 	
+
 /var/www/yii-1.1.13/framework/base/CModule.php(103): CModule->getComponent("user")
#10 	
–
 /var/www/eesystem/protected/components/Controller.php(23): CModule->__get("user")

18      * @var array the breadcrumbs of the current page. The value of this property will
19      * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
20      * for more details on how to specify this property.
21      */
22         public function init() {
23             if(Yii::app()->user->isGuest) {
24                 echo "JJJ";
25                 //Yii::app()->user->loginRequired();
26             }
27         }
28     public $breadcrumbs=array();

#11 	
+
 /var/www/yii-1.1.13/framework/web/CWebApplication.php(281): Controller->init()
#12 	
+
 /var/www/yii-1.1.13/framework/web/CWebApplication.php(141): CWebApplication->runController("")
#13 	
+
 /var/www/yii-1.1.13/framework/base/CApplication.php(169): CWebApplication->processRequest()
#14 	
–
 /var/www/eesystem/index.php(25): CApplication->run()

20 require_once($helpers);
21 require_once($pdfhelpers);
22 //require_once($firephp1);
23 //require_once($firephp2);
24 
25 Yii::createWebApplication($config)->run();

2013-06-28 23:33:59 Apache/2.2.22 (Ubuntu) Yii Framework/1.1.13



Please help.
0

#2 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 891
  • Joined: 19-February 13
  • Location:India

Posted 28 June 2013 - 07:46 AM

Hi

Can u post your code config/main.php
Thanks,
Ankit Modi
Skype : amodi06
0

#3 User is offline   VINAY Kr. SHARMA 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 13-September 11
  • Location:Gurgaon

Posted 28 June 2013 - 09:17 AM

Double check your connection string. It could be you have mistyped.

Connection String should be like this:

...
// FOR MySQL
'connectionString' => 'mysql:host=127.0.0.1;port=3306;dbname=mydatabase;'
// FOR PgSQL
'connectionString' => 'pgsql:host=127.0.0.1;port=5432;dbname=mydatabase;'
// FOR SQLite
'connectionString' => 'sqlite:path/to/dbfile...'

VINAY Kr. SHARMA
@vinaykrsharma
Facebook ID: vinaykrsharma
Blog

Co-operation comes from friendship, friendship comes from trust, and trust comes from kind-heartedness.
0

#4 User is offline   Samrat Kar 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 11-June 12
  • Location:Mumbai

Posted 28 June 2013 - 10:11 AM

But same code is working on XAMPP (windows). While published on LAMP (Ubuntu), problem started appearing.
Just a doubt, is there anything to do with PHP SESSION?
0

#5 User is offline   hemc 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 87
  • Joined: 09-July 12
  • Location:New Delhi

Posted 29 June 2013 - 12:11 AM

Install mysql driver on server, or provide the path of existing driver to system path.
Please don't add a reply to say thanks, There is already a +1 button to do same.
0

#6 User is offline   Samrat Kar 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 11-June 12
  • Location:Mumbai

Posted 30 June 2013 - 11:41 PM

mysql is already installed on server, but i don't know how to give path to the driver.
0

#7 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 891
  • Joined: 19-February 13
  • Location:India

Posted 01 July 2013 - 12:00 AM

Hi
please remove the colon after Db name

'connectionString' => 'mysql:host=127.0.0.1;port=3306;dbname=mydatabase'


somrhthing lookl like this
$configArray['components']['db'] = array(
        'connectionString' => 'mysql:host=127.0.0.1;dbname=test',

        'emulatePrepare' => true,
        'username' => 'other',
        'password' => 'password',
        'charset' => 'utf8',
);

Thanks,
Ankit Modi
Skype : amodi06
0

#8 User is offline   Samrat Kar 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 11-June 12
  • Location:Mumbai

Posted 01 July 2013 - 12:12 AM

Please see the config file main.php below. There is no extra colon in dbstring.

<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.

//require_once(dirname(_FILE_) . '/../components/helpers.php');
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
        /*'behaviors'=>array(
            'onBeginRequest'=>array(
                'class'=>'application.components.RequireLogin',
            ),
        ),*/
	'name'=>'Electrical Maintenance',

	// preloading components
	'preload'=>array(
            'log',
            //'bootstrap',
            ),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
                'application.modules.user.models.*',
	),

	'modules'=>array(
		// uncomment the following to enable the Gii tool
		
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'samrat',
		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
                        /*'generatorPaths'=>array(
                            'bootstrap.gii',                            
                        ),*/
		),
                'eeconfig',
                'user' => array(
                    'debug' => false,
                    'userTable' => 'user',
                    'translationTable' => 'translation',
                ),
                'usergroup' => array(
                    'usergroupTable' => 'user_group',
                    'usergroupMessagesTable' => 'user_group_message',
                ),
                'membership' => array(
                    'membershipTable' => 'membership',
                    'paymentTable' => 'payment',
                ),
                'friendship' => array(
                    'friendshipTable' => 'friendship',
                ),
                'profile' => array(
                    'privacySettingTable' => 'privacysetting',
                    'profileFieldTable' => 'profile_field',
                    'profileTable' => 'profile',
                    'profileCommentTable' => 'profile_comment',
                    'profileVisitTable' => 'profile_visit',
                ),
                'role' => array(
                    'roleTable' => 'role',
                    'userRoleTable' => 'user_role',
                    'actionTable' => 'action',
                    'permissionTable' => 'permission',
                ),
                'message' => array(
                    'messageTable' => 'message',
                ),		
	),

	// application components
	'components'=>array(
		'user'=>array(
                    'class'=>'application.modules.user.components.YumWebUser',
                    // enable cookie-based authentication
                    'allowAutoLogin'=>true,
                    'loginUrl'=>array('//user/user/login'),
		),
                'cache'=>array(
                    'class'=>'CApcCache',                    
                ),
		// uncomment the following to enable URLs in path-format
		/*
		'urlManager'=>array(
			'urlFormat'=>'path',
			'rules'=>array(
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),
		*/
		/*'db'=>array(
			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
		),*/
		// uncomment the following to use a MySQL database
		'db'=>array(
			'connectionString' => 'mysql:host=192.168.55.1;dbname=eesystem',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => 'xxxxxx',
			'charset' => 'utf8',
                        'tablePrefix'=>'',
		),
		
		'errorHandler'=>array(
                    // use 'site/error' action to display errors
                    'errorAction'=>'site/error',
                ),
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
                                    'class'=>'CFileLogRoute',
                                    'levels'=>'error, warning',
				),
                                /*array(
                                    'class'=>'CWebLogRoute',
                                    'categories'=>'system.db.CDbCommand',
                                    'showInFireBug'=>true,
                                ),*/
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
                'session'=>array(
                    'class'=>'CDbHttpSession',
                    'timeout'=>900,
                ),
                /*'bootstrap'=>array(
                    'class'=>'ext.bootstrap.components.Bootstrap',  
                    'coreCss'=>false,
                ),*/
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>array(
		// this is used in contact page
		'adminEmail'=>'webmaster@example.com',
	),
        'theme'=>'sk_theme1',
);

0

#9 User is offline   redguy 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 809
  • Joined: 02-July 10
  • Location:Central Poland

Posted 01 July 2013 - 01:21 AM

run phpinfo() and check what pdo_* extensions are installed. if there is no pdo_mysql - you must install it or enable in php.ini config file.
red
0

#10 User is offline   Samrat Kar 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 11-June 12
  • Location:Mumbai

Posted 01 July 2013 - 01:31 AM

View Postredguy, on 01 July 2013 - 01:21 AM, said:

run phpinfo() and check what pdo_* extensions are installed. if there is no pdo_mysql - you must install it or enable in php.ini config file.


Checked phpinfo() pdo_mysql is already installed.

Attached File(s)

  • Attached File  scc.png (16.22K)
    Number of downloads: 18

0

#11 User is offline   nachi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 27-January 12
  • Location:Madurai

Posted 24 September 2014 - 05:27 AM

View PostSamrat Kar, on 01 July 2013 - 12:12 AM, said:

Please see the config file main.php below. There is no extra colon in dbstring.

<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.

//require_once(dirname(_FILE_) . '/../components/helpers.php');
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
        /*'behaviors'=>array(
            'onBeginRequest'=>array(
                'class'=>'application.components.RequireLogin',
            ),
        ),*/
	'name'=>'Electrical Maintenance',

	// preloading components
	'preload'=>array(
            'log',
            //'bootstrap',
            ),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
                'application.modules.user.models.*',
	),

	'modules'=>array(
		// uncomment the following to enable the Gii tool
		
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'samrat',
		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
                        /*'generatorPaths'=>array(
                            'bootstrap.gii',                            
                        ),*/
		),
                'eeconfig',
                'user' => array(
                    'debug' => false,
                    'userTable' => 'user',
                    'translationTable' => 'translation',
                ),
                'usergroup' => array(
                    'usergroupTable' => 'user_group',
                    'usergroupMessagesTable' => 'user_group_message',
                ),
                'membership' => array(
                    'membershipTable' => 'membership',
                    'paymentTable' => 'payment',
                ),
                'friendship' => array(
                    'friendshipTable' => 'friendship',
                ),
                'profile' => array(
                    'privacySettingTable' => 'privacysetting',
                    'profileFieldTable' => 'profile_field',
                    'profileTable' => 'profile',
                    'profileCommentTable' => 'profile_comment',
                    'profileVisitTable' => 'profile_visit',
                ),
                'role' => array(
                    'roleTable' => 'role',
                    'userRoleTable' => 'user_role',
                    'actionTable' => 'action',
                    'permissionTable' => 'permission',
                ),
                'message' => array(
                    'messageTable' => 'message',
                ),		
	),

	// application components
	'components'=>array(
		'user'=>array(
                    'class'=>'application.modules.user.components.YumWebUser',
                    // enable cookie-based authentication
                    'allowAutoLogin'=>true,
                    'loginUrl'=>array('//user/user/login'),
		),
                'cache'=>array(
                    'class'=>'CApcCache',                    
                ),
		// uncomment the following to enable URLs in path-format
		/*
		'urlManager'=>array(
			'urlFormat'=>'path',
			'rules'=>array(
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),
		*/
		/*'db'=>array(
			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
		),*/
		// uncomment the following to use a MySQL database
		'db'=>array(
			'connectionString' => 'mysql:host=192.168.55.1;dbname=eesystem',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => 'xxxxxx',
			'charset' => 'utf8',
                        'tablePrefix'=>'',
		),
		
		'errorHandler'=>array(
                    // use 'site/error' action to display errors
                    'errorAction'=>'site/error',
                ),
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
                                    'class'=>'CFileLogRoute',
                                    'levels'=>'error, warning',
				),
                                /*array(
                                    'class'=>'CWebLogRoute',
                                    'categories'=>'system.db.CDbCommand',
                                    'showInFireBug'=>true,
                                ),*/
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
                'session'=>array(
                    'class'=>'CDbHttpSession',
                    'timeout'=>900,
                ),
                /*'bootstrap'=>array(
                    'class'=>'ext.bootstrap.components.Bootstrap',  
                    'coreCss'=>false,
                ),*/
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>array(
		// this is used in contact page
		'adminEmail'=>'webmaster@example.com',
	),
        'theme'=>'sk_theme1',
);




Kindly remove this line, it will work fine.
'session'=>array(
                    'class'=>'CDbHttpSession',
                    'timeout'=>900,
                ),

Nachi,
Web Developer,
India,
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users