dstwfcz1377 2015-07-19 08:49
浏览 63
已采纳

致命! 用户postgres的身份验证失败,操作系统倍数,无效

This is my first time with Apache, php and postgresql. This is what I did:

  • I installed postgresql, wapp y pgadmin3,
  • I copied the file with my project in apache/htdocs,
  • open the index and try to enter in the user account of my web, but it said:

"Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] FATAL: the authentication failed for the user «'postgres'»' in C:\Bitnami\wappstack-5.5.27-0\apache2\htdocs\PROJECT\formss\class\connection.php:31 Stack trace: #0 C:\Bitnami\wappstack-5.5.27-0\apache2\htdocs\PROJECT\forms\class\connection.php(31): PDO->__construct('pgsql:host=127....', ''postgres'', ''12345'') #1 C:\Bitnami\wappstack-5.5.27-0\apache2\htdocs\PROJECT\forms\actions\user_login.php(6): connection->__construct() #2 {main} thrown in C:\Bitnami\wappstack-5.5.27-0\apache2\htdocs\PROJECT\forms\class\conection.php on line 31"

The pass that I set for the user postgress was 12345 in every step. Pgadmin3 let me change everything inside the db.

I already tried all these in Ubuntu but without a stack, it said the same. I checked the config of postgresql and see that for all the users say md5 like a lot of people suggest in other questions about this (yes, I searched and tried many solutions but they did not work for me).

The REAL problem is that with the exact same file, the project works in my office, with windows 7, now, with a clean installation of W7 and Ubuntu 14.04, don't want anything.

This is the connection code:

 <?php
    class connection {
        private $database;
        private $host;
        private $port;
        private $user;
        private $pass;
        public $db;
        public function __construct(){
            $this->user='postgres';
            $this->pass='12345';
            $this->host='localhost';
            $this->database='project';
            $this->port=5432;
            $this->db=new PDO("pgsql:host=".$this->host.
                ";port=".$this->port.
                ";dbname=".$this->database
                ,"'".$this->user."'"
                ,"'".$this->pass."'");
            $this->db->exec("SET CHARACTER SET utf8");
            return $this->db;
        }
        public function __clone(){
            trigger_error('The clone is not allowed', E_USER_ERROR);
        }
    }
?>
  • 写回答

1条回答 默认 最新

  • dongzhuifeng1843 2015-07-19 10:12
    关注

    As per the comment discussion, the code that creates the database connection seems to be problematic:

            $this->db=new PDO("pgsql:host=".$this->host.
                ";port=".$this->port.
                ";dbname=".$this->database
                ,"'".$this->user."'"
                ,"'".$this->pass."'");
    

    It is very unusual to wrap the username and password in quote marks, I have never see this before. We discovered in the comments that removing the quotes got the connection working again.

    You may wish to discuss with a colleague why the database server in the office works with this unusual approach. It is possible that user accounts are disabled in some fashion, perhaps because it is a LAN-only database, and all connections are permitted.

    It is also worth approaching the author of this code, in case they have some knowledge about the system that you do not. I would expect this unusual code to have been commented, so discussing it may be the next best thing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图