進入DB配置爲安裝訪問被拒絕的用戶 '根' @ '本地主機'(使用密碼:否)YII
錯誤500 的mysql_connect之後接收錯誤()[function.mysql-連接]:訪問被拒絕的用戶 '根' @ 'localhost' 的(使用密碼:NO)
Db的配置文件(默認)
(
return array (
'connectionString' => 'mysql:host=localhost;dbname=sarish',
'emulatePrepare' => true,
'username' => 'sarish',
'password' => '[email protected]',
'charset' => 'utf8',
);
好心幫我
這是安裝控制器代碼
<?php
/** * 權利安裝控制器類文件。
*/ 類InstallController擴展RController { /** * @property RAuthorizer */ 私人$ _authorizer; /** * @property RInstaller */ private $ _installer;
/**
* Initializes the controller.
*/
public function init()
{
if($this->module->install!==true)
$this->redirect(Yii::app()->homeUrl);
$this->_authorizer = $this->module->getAuthorizer();
$this->_installer = $this->module->getInstaller();
$this->layout = $this->module->layout;
$this->defaultAction = 'run';
// Register the scripts.
$this->module->registerScripts();
}
/**
* @return array action filters
*/
public function filters()
{
// Use access control when installed.
return $this->_installer->installed===true ? array('accessControl') : array();
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // Allow superusers to access Rights
'actions'=>array(
'confirm',
'run',
'error',
'ready',
),
'users'=>$this->_authorizer->getSuperusers(),
),
array('deny', // Deny all users
'users'=>array('*'),
),
);
}
/**
* Displays the confirm overwrite page.
*/
public function actionConfirm()
{
$this->render('confirm');
}
/**
* Installs the module.
* @throws CHttpException if the user is not logged in.
*/
public function actionRun()
{
// Make sure the user is not a guest.
if(Yii::app()->user->isGuest===false)
{
// Make sure that the module is not already installed.
if(isset($_GET['confirm'])===true || $this->_installer->installed===false)
{
// Run the installer and check for an error.
if($this->_installer->run()===RInstaller::ERROR_NONE)
{
// Mark the user to have superuser privileges.
Yii::app()->user->isSuperuser = true;
$this->redirect(array('install/ready'));
}
// Redirect to the error page.
$this->redirect(array('install/error'));
}
// Module is already installed.
else
{
$this->redirect(array('install/confirm'));
}
}
// User is guest, deny access.
else
{
$this->accessDenied(Rights::t('install', 'You must be logged in to install Rights.'));
}
}
/**
* Displays the install ready page.
*/
public function actionReady()
{
$this->render('ready');
}
/**
* Displays the install ready page.
*/
public function actionError()
{
$this->render('error');
}
}
你的數據庫連接是錯誤的,所以這會引發錯誤。這是非常基本的事情,請在問這樣簡單的問題之前去谷歌。 – 2014-10-09 13:23:21
而你不應該給你密碼! – consuela 2014-10-10 10:00:50