简体   繁体   中英

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

I am trying to use the yii framework for a while. I have been referring - first-app-doc and yiic-doc .

I have read all the posts related to mine on "stackoverflow" but couldn't get any luck resolving my problem. Mostly because I am stuck on the .ini files and the pdo .

I have modified the config file- protected/config/main.php according to my database configuration. I am using the command line tool - yiic to create the model . It gives me 'http://hostname/path/to/index.php?r=user' to hit.

When I hit http://localhost/index.php?r=user ; it gives CDbException - CDbConnection failed to open the DB connection: could not find driver in the browser itself. It seems like it can't find the pdo_mysql .
Also, I don't have the php.ini file in /etc/php5/ , but I have different php.ini files in /etc/php5/cgi/ , /etc/php5/apache2/ and /etc/php5/cli/ .

Also, the php5-mysql package, I have it installed on my computer.

I have been trying and trying. This is like impossible to do.

I know this is a little old question now but hopefully it can help other people, I actually had the same issue I was using it on Google Compute engine where we set up the server and we found out you have to install sqlite PDO extension as well as the MySQL PDO extension.

More information is on my question: https://stackoverflow.com/a/24555366/817213

Hopefully this can help other people too.

1- try to access the database with MAMP or WAMP or XAMP, or even by command line first. you will then know if you need a username and password for that.

2- check what databases you have. you will know then if the database exists or not.

3- check the database connection string in the project if it's correct or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM