Yii CDbConnection无法打开数据库连接:找不到带有Google Cloud SQL的驱动程序 [英] Yii CDbConnection failed to open the DB connection: could not find driver with google cloud sql

查看:123
本文介绍了Yii CDbConnection无法打开数据库连接:找不到带有Google Cloud SQL的驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Yii和在Google Cloud sql上运行的mysql数据库时遇到问题.

I'm having an issue with Yii and a mysql database running on Google Cloud sql.

快速概述:

我们已将其从现有服务器移出,该服务器在所有服务器上都没有问题,现在已经安装了带有php的Google Compute Engine服务器,所有相关驱动程序mysql_pdo就是其中之一.我们还有一个Google Cloud SQL数据库,用于存储我们所有现有的数据库信息.

We have moved this from an existing server where it all worked with no issues at all and have now set up a Google Compute Engine server with php and all the relivant drivers mysql_pdo being one of them. We also have a Google Cloud SQL database storing all of our existing database information.

我尝试过的事情

我写了一个简单的PHP脚本,它使用 PDO('mysql:<IPADDRESS>;dbname=<MYDBNAME>,'MYUSERNAME','MYPASSWORD');,这连接起来非常好,可以读取表并返回数据.

I have written a simple php script which uses PDO('mysql:<IPADDRESS>;dbname=<MYDBNAME>,'MYUSERNAME','MYPASSWORD'); and this connects absolutely fine and can read tables and return data.

问题

一旦我在config/main.php中的yii中执行相同的操作,它似乎就无法工作并出现错误: CDbConnection无法打开数据库连接:找不到驱动程序

As soon as I do the same in yii in the config/main.php it does not seem to work and get the error: CDbConnection failed to open the DB connection: could not find driver

这是yii连接字符串

'db'=>array(
                    'connectionString' =>'mysql:host=my.server.ip.address;dbname=my_db_name',
                    'emulatePrepare' => true,
                    'username' => 'my_username',
                    'password' => 'my_passsword',
                    'charset' => 'utf8',
            ),

我还运行了yii Requirements脚本,它全部返回为mysql PDO函数传递的值.

I've also run the yii requirements script and it all returns as passed for the mysql PDO functions.

任何帮助将不胜感激.

谢谢

推荐答案

啊哈回答我自己的问题:

Aha answering my own question:

服务器需要具有sqlite PDO扩展以及MySQL PDO扩展.现在一切正常!

The server needs to have sqlite PDO extension as well as the MySQL PDO extension. And now all working perfectly!

因此值得为此检查phpinfo

So it's worthwhile checking you phpinfo for this

您可以根据以下答案添加它: https://superuser.com/a/320914

You can add it according to this answer: https://superuser.com/a/320914

或通过您的php.ini取消注释以下内容:

or via your php.ini uncomment the following:

extension=php_pdo_sqlite.dll

extension=php_sqlite.dll

希望这对其他人有帮助

这篇关于Yii CDbConnection无法打开数据库连接:找不到带有Google Cloud SQL的驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆