用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1525|回复: 3
收起左侧

[HELP] CI框架连接数据库密码莫名清空

[复制链接]
发表于 2014-12-15 11:12:50 | 显示全部楼层 |阅读模式
    各位大神好,小弟是php新手。先介绍下个人问题,这个项目是用ci框架搭建的后台管理系统,数据库使用mysql. 我在部署在内网时出现点错误,在连接数据库的时候密码莫名清空了。 我在/database/drivers/mysql/mysql_driver.php中 db_connect()函数里面写了个日志,
    function db_connect()
    {
        if ($this->port != '')
        {
            $this->hostname .= ':'.$this->port;
        }
        log_message('error',"======================");
        log_message('error',"hostname=".$this->hostname);
        log_message('error',"username=".$this->username);
        log_message('error',"password=".$this->password);
        log_message('error',"======================");
        
        return @mysql_connect($this->hostname, $this->username, $this->password, TRUE);
        
    }

数据库配置在application/config/production/database.php,里面配置了相关的数据库信息。
。在查看日志时发现 (最开始的时候有取到password,后面几次都是password都为空的,不知道为什么)。
ERROR - 2014-12-15 11:05:41 --> hostname=127.0.0.1
ERROR - 2014-12-15 11:05:41 --> username=root
ERROR - 2014-12-15 11:05:41 --> password=******(这次能取到)
ERROR - 2014-12-15 11:05:41 --> ======================
ERROR - 2014-12-15 11:05:41 --> ======================
ERROR - 2014-12-15 11:05:41 --> hostname=127.0.0.1
ERROR - 2014-12-15 11:05:41 --> username=root
ERROR - 2014-12-15 11:05:41 --> password=
ERROR - 2014-12-15 11:05:41 --> ======================
ERROR - 2014-12-15 10:55:04 --> Severity: Warning  --> mysql_connect(): Access denied for user 'root'@'127.0.0.1' (using password: NO) /home/hulq/s01/jssg1/login/website/s_jssg/common/cilib/database/drivers/mysql/mysql_driver.php 78
ERROR - 2014-12-15 10:55:04 --> Unable to connect to the database
ERROR - 2014-12-15 10:55:04 --> ======================
ERROR - 2014-12-15 10:55:04 --> hostname=127.0.0.1
ERROR - 2014-12-15 10:55:04 --> username=root
ERROR - 2014-12-15 10:55:04 --> password=
ERROR - 2014-12-15 10:55:04 --> ======================
ERROR - 2014-12-15 10:55:04 --> Severity: Warning  --> mysql_connect(): Access denied for user 'root'@'127.0.0.1' (using password: NO) /home/hulq/s01/jssg1/login/website/s_jssg/common/cilib/database/drivers/mysql/mysql_driver.php 78
ERROR - 2014-12-15 10:55:04 --> Unable to connect to the database

研究了很久没发现问题,希望各位大大帮助了一下。


发表于 2014-12-15 15:59:50 | 显示全部楼层
配置文件config/database.php,把12.7.0.0.1改成localhost试试
 楼主| 发表于 2014-12-15 17:47:35 | 显示全部楼层
aqxinzhuan 发表于 2014-12-15 15:59
配置文件config/database.php,把12.7.0.0.1改成localhost试试

试了, 上面这个问题还有。多了个问题 Can't connect to local MySQL server through socket '/data/mysql/mysql.sock'。

感觉127.0.0.1和localhost没什么影响吧?

发表于 2014-12-15 19:30:51 | 显示全部楼层
Sylar_Ci123 发表于 2014-12-15 17:47
试了, 上面这个问题还有。多了个问题 Can't connect to local MySQL server through socket '/data/mysq ...

localhost是socket连接,127.0.0.1等IP地址的是TCP/IP连接

本版积分规则