当我试图连接到我的数据库Yii时出现此错误访问被拒绝连接到mysql与yii
我确信密码和权限是正确的。我如何在这里找到问题?
我正在运行MAMP和最新的Yii。
CDbException
CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user 'yii'@'localhost' (using password: YES)
/Users/user/Dropbox/localhost/yii/framework/gii/generators/model/ModelCode.php(54)
42 ));
43 }
44
45 public function requiredTemplates()
46 {
47 return array(
48 'model.php',
49 );
50 }
51
52 public function init()
53 {
54 if(Yii::app()->db===null)
55 throw new CHttpException(500,'An active "db" connection is required to run this generator.');
56 $this->tablePrefix=Yii::app()->db->tablePrefix;
57 parent::init();
58 }
59
60 public function prepare()
61 {
62 if(($pos=strrpos($this->tableName,'.'))!==false)
63 {
64 $schema=substr($this->tableName,0,$pos);
65 $tableName=substr($this->tableName,$pos+1);
66 }
您要么使用发出请求的主机发送错误的用户名,要么使用错误的密码。 (MySQL用户/密码对可以是主机特定的)... – ircmaxell
你的db连接信息不正确。检查你的配置关于数据库信息。 – RusAlex
你可以在myapp/protected/config/main.php文件中的db连接配置数组中显示代码吗? Plus显示'mysql>的输出SELECT用户,主机,密码FROM mysql.user;'? –