用户信息的数据库校验时报错
来源:4-5 异步方式实现登录功能—用户信息的数据库校验
zoe呀
2017-08-22
<p class="face">:(</p> <h1>SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)</h1> <div class="content"> <div class="info"> <div class="title"> <h3>错误位置</h3> </div> <div class="text"> <p>FILE: /data/webroot/ThinkPHP/Library/Think/Db/Driver.class.php  LINE: 109</p> </div> </div>
<?php return array( 'DB_TYPE' => 'mysql', 'DB_HOST' => '127.0.0.1', 'DB_USER' => 'root', 'DB_PWD' => '', 'DB_PORT' => 3306, 'DB_NAME' => 'imooc_singcms', 'DB_CHARSET' => 'utf8', 'DB_PREFIX' =>'cms_', );
<?php namespace Common\Model; use Think\Model; class AdminModel extends Model{ private $_db = ''; public function __construct() { $this->_db = M('admin'); } public function getAdminByUsername($username) { $res = $this->_db->where('username="'.$username.'"')->find(); return $res; } }
$ret = D('Admin')->getAdminByUsername($username); print_r($ret);
出错信息说是SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
是数据库的用户名密码写错了吗?
写回答
1回答
-
您好,您本地的mysql数据库用户名和密码是否填写正确了?
022017-08-23
相似问题