title: access denied connecting to mysql with yii
body: <p>I get this error when trying to connect to my db with Yii</p>
  
  <p>I am sure the password and permissions are correct. How do I track down the problem here?</p>
  
  <p>I am running MAMP and the latest Yii.</p>
  
  <pre><code>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()-&gt;db===null)
  55             throw new CHttpException(500,'An active "db" connection is required to run this generator.');
  56         $this-&gt;tablePrefix=Yii::app()-&gt;db-&gt;tablePrefix;
  57         parent::init();
  58     }
  59 
  60     public function prepare()
  61     {
  62         if(($pos=strrpos($this-&gt;tableName,'.'))!==false)
  63         {
  64             $schema=substr($this-&gt;tableName,0,$pos);
  65             $tableName=substr($this-&gt;tableName,$pos+1);
  66         }
  </code></pre>