我已将 yii 框架 Web 应用程序迁移到 1&1 服务器,但在连接数据库时遇到问题。错误是:
CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2002] Connection refused
在我的 config/main.php 中我有这个:
'db'=>array(
'connectionString' => 'mysql:host=localhost:/tmp/mysql5.sock;dbname=nombrebasededatos',
'emulatePrepare' => true,
'username' => 'nombreusuario',
'password' => 'password,',
'charset' => 'utf8',
),
为什么这种事会发生在我身上?
最佳答案
正如评论中提到的,1and1 不使用 localhost 作为主机并在最后删除套接字,因此请尝试
'db'=>array(
'connectionString' => 'mysql:host=nombreusuario.db.1and1.com;dbname=nombrebasededatos',
'emulatePrepare' => true,
'username' => 'nombreusuario',
'password' => 'password,',
'charset' => 'utf8',
),
关于mysql - Yii 1&1 DBConnection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21319355/