2015-09-08 16:33:17 7200次浏览 4条回答 0 悬赏 30 金钱

在本地和测试服务器上运行没有问题,在将测试服务器所有内容复制到生产服务器后出现数据库连接错误下面是出错信息

2015-09-08 16:12:32 [115.198.131.186][-][-][error][yii\db\Exception] exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user 'laiqian_root'@'10.164.29.218' (using password: YES)' in /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/Connection.php:579
Stack trace:
#0 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/Connection.php(579): PDO->__construct('mysql:host=rdst...', 'root', 'jq2&8=7m+', NULL)
#1 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/Connection.php(529): yii\db\Connection->createPdoInstance()
#2 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/Connection.php(836): yii\db\Connection->open()
#3 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/Connection.php(823): yii\db\Connection->getMasterPdo()
#4 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/Command.php(208): yii\db\Connection->getSlavePdo()
#5 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/Command.php(815): yii\db\Command->prepare(true)
#6 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/Command.php(350): yii\db\Command->queryInternal('fetchAll', NULL)
#7 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/mysql/Schema.php(198): yii\db\Command->queryAll()
#8 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/mysql/Schema.php(97): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))
#9 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/Schema.php(139): yii\db\mysql\Schema->loadTableSchema('t_shop')
#10 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/ActiveRecord.php(297): yii\db\Schema->getTableSchema('t_shop')
#11 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/ActiveRecord.php(320): yii\db\ActiveRecord::getTableSchema()
#12 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/ActiveRecord.php(179): yii\db\ActiveRecord::primaryKey()
#13 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/db/BaseActiveRecord.php(101): yii\db\ActiveRecord::findByCondition('235360', true)
#14 /home/wwwroot/default/pos/posweb2/controllers/ShopController.php(185): yii\db\BaseActiveRecord::findOne('235360')
#15 /home/wwwroot/default/pos/posweb2/controllers/ShopController.php(15): app\controllers\ShopController->findShop('235360')
#16 [internal function]: app\controllers\ShopController->actionIndex('235360')
#17 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#18 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#19 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/base/Module.php(455): yii\base\Controller->runAction('index', Array)
#20 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/web/Application.php(83): yii\base\Module->runAction('shop/index', Array)
#21 /home/wwwroot/default/pos/posweb2/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#22 /home/wwwroot/default/pos/posweb2/web/index.php(51): yii\base\Application->run()
#23 {main}
  • 回答于 2015-09-08 16:35 举报

    可能数据库密码错了

    3 条回复
    回复于 2015-09-08 16:36 回复

    应该没有出错,使用原生的php代码来连接是可以的

    回复于 2015-09-08 16:38 回复

    看看连接地址对不对

    回复于 2015-09-10 14:52 回复

    问题已解决,是阿里的rds数据库的白名单没打开,访问不到数据库,谢谢大家的回答

  • 回答于 2015-09-08 22:20 举报

    拒绝连接? 还是再检查下账号密码...

  • 回答于 2015-09-09 09:48 举报

    看看错误信息和#0的信息好像账号就不一致啊

  • 回答于 2015-09-09 10:54 举报

    检查一下数据库授权信息,是不是laiqian_root这个账号没有给10.164.29.218授权

    1 条回复
    回复于 2016-03-02 22:53 回复

    我也遇到了这个问题

您需要登录后才可以回答。登录 | 立即注册
心雨
主管

心雨

注册时间:2015-07-23
最后登录:2020-03-31
在线时长:20小时35分
  • 粉丝5
  • 金钱175
  • 威望20
  • 积分575

热门问题