PHP - Codeigniter - 连接到PostgreSQL失败 [英] PHP - Codeigniter - Connecting to a PostgreSQL fails

查看:192
本文介绍了PHP - Codeigniter - 连接到PostgreSQL失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对CodeIgniter很新,但我已经开发了过去的几个工作页面。我试图重构这些页面(旧页面仍然在一个Linux盒子里的Postgres),并在Windows框中进行开发;但我遇到了Postgres数据库连接问题,并得到以下错误:

I’m pretty new to CodeIgniter, but I have developed a few working pages in the past. I’m trying to refactor those pages (the old pages are still running in a Linux box on Postgres) and developing them in a Windows box; but I’m stuck with a Postgres database connectivity issue and I’m getting the following error:


发生数据库错误

A Database Error Occurred

无法使用提供的设置连接到数据库服务器。

Unable to connect to your database server using the provided settings.

文件名:C:\Subayogam_v2.0\Codeigniter \system\database\DB_driver.php

行号:124

Filename: C:\Subayogam_v2.0\Codeigniter\system\database\DB_driver.php
Line Number: 124

我知道这个错误当数据库配置丢失时出现,但我有一个有效的数据库配置在C:\Subayogam_v2.0\Codeigniter\application\config\database.php。下面是配置文件数据:

I know that this error comes up when the database configuration is missing, but I do have a valid DB configuration at C:\Subayogam_v2.0\Codeigniter\application\config\database.php. Given below is the config file data:

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'postgres';
$db['default']['password'] = 'mypassword';
$db['default']['database'] = 'subayogam_v2.0';
$db['default']['dbdriver'] = 'postgre';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = TRUE;
/*$db['default']['cachedir'] = '/var/subayogam_2.0/cache';*/
$db['default']['cachedir'] = 'C:\Subayogam_v2.0\Codeigniter\cache';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

我双重检查缓存文件夹路径,并尝试了一个简单的PHP页面连接到同一个DB看看驱动程序是否工作,我能够从数据库中查看结果。 Apache错误日志中也没有有用的错误消息。我从运行的版本粘贴了整个应用程序,并修改了DB文件指向新的数据库。没有其他更改。

I double checked the cache folder path and also tried a simple PHP page that connects to the same DB to see if the drivers are working, and I’m able to see results from the database. No useful error messages in Apache error log either. I've copy pasted the entire application from the running version and modified the DB file to point to the new database. Nothing else has changed.

什么可能是错误?是否有任何特定的日志文件可以为我提供更多的错误信息?

What could be wrong? Is there any specific log file that can provide me with more information on the error?

推荐答案

我首先设置codeigniter与postgres。 Postgres在不同的端口上运行,因此您需要在数据库配置中指定端口; 5432是默认端口postgres选择,因为我已经安装了mysql。

I've had a similar problem when i first setup codeigniter with postgres. Postgres runs on a different port, so you'll need specify the port in the database configuration as such; 5432 was the default port postgres chose since i already had mysql installed.



    $db['default']['port'] = 5432; 

这篇关于PHP - Codeigniter - 连接到PostgreSQL失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆