简体   繁体   English

yii CDbException:CDbConnection 无法打开数据库连接:找不到驱动程序

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

I am trying to use the yii framework for a while.我正在尝试使用yii框架一段时间。 I have been referring - first-app-doc and yiic-doc .我一直在指 - first-app-docyiic-doc

I have read all the posts related to mine on "stackoverflow" but couldn't get any luck resolving my problem.我已经阅读了“stackoverflow”上与我的所有相关的帖子,但无法解决我的问题。 Mostly because I am stuck on the .ini files and the pdo .主要是因为我被困在.ini文件和pdo

I have modified the config file- protected/config/main.php according to my database configuration.我已经根据我的数据库配置修改了配置文件-protected protected/config/main.php I am using the command line tool - yiic to create the model .我正在使用命令行工具yiic创建model It gives me 'http://hostname/path/to/index.php?r=user' to hit.它让我点击'http://hostname/path/to/index.php?r=user'。

When I hit http://localhost/index.php?r=user ;当我点击http://localhost/index.php?r=user it gives CDbException - CDbConnection failed to open the DB connection: could not find driver in the browser itself.它给出了CDbException - CDbConnection failed to open the DB connection: could not find driver在浏览器本身中CDbConnection failed to open the DB connection: could not find driver It seems like it can't find the pdo_mysql .似乎找不到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/ .另外,我不具备php.ini文件/etc/php5/ ,但我有不同php.ini文件中/etc/php5/cgi//etc/php5/apache2//etc/php5/cli/ .

Also, the php5-mysql package, I have it installed on my computer.另外, php5-mysql包,我已经安装在我的电脑上。

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.我知道这是一个有点老的问题,但希望它可以帮助其他人,我实际上遇到了同样的问题,我在 Google Compute 引擎上使用它我们设置了服务器,我们发现您还必须安装 sqlite PDO 扩展作为 MySQL PDO 扩展。

More information is on my question: https://stackoverflow.com/a/24555366/817213更多信息是关于我的问题: 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. 1- 尝试使用 MAMP 或 WAMP 或 XAMP 访问数据库,甚至首先通过命令行访问。 you will then know if you need a username and password for that.然后您就会知道是否需要用户名和密码。

2- check what databases you have. 2-检查您拥有哪些数据库。 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. 3-检查项目中的数据库连接字符串是否正确。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CDbConnection无法打开数据库连接:在Yii中找不到驱动程序 - CDbConnection failed to open the DB connection: could not find driver in Yii CDbConnection无法打开数据库连接:在Yii中使用ORACLE数据库时找不到驱动程序 - CDbConnection failed to open the DB connection: could not find driver while using ORACLE database in Yii Yii CDbConnection无法打开数据库连接:找不到google cloud sql的驱动程序 - Yii CDbConnection failed to open the DB connection: could not find driver with google cloud sql Yii 1.1.x CDbHttpSession错误:CDbConnection无法打开数据库连接:找不到驱动程序 - Yii 1.1.x CDbHttpSession error: CDbConnection failed to open the DB connection: could not find driver 尝试生成模型类时,“ CDbConnection无法打开数据库连接:找不到驱动程序” - 'CDbConnection failed to open the DB connection: could not find driver' while trying to generate a model class CDbConnection无法打开数据库连接Yii - CDbConnection failed to open the DB connection Yii MySQL:CDbConnection 无法打开数据库连接 - MySQL: CDbConnection failed to open the DB connection yiic:CDbConnection无法打开数据库连接 - yiic: CDbConnection failed to open the DB connection CDbConnection无法打开数据库连接:无法打开数据库文件 - CDbConnection failed to open the DB connection: unable to open database file Echofish错误500“ CDbConnection无法打开数据库连接” - Echofish Error 500 “CDbConnection failed to open the DB connection”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM