我是新手刚接触postgresql 编程
系统是 ubuntu 6.06LTS
安装了 postgresql 8.1.9 默认设置
用户名 postgres 密码111
程序如下
#include <stdio.h>
#include <stdlib.h>
#include <postgresql/libpq-fe.h>
int main()
{
PGconn *conn;
const char *str = "host=localhost dbname=mydb";
conn = PQconnectdb(str);
if(PQstatus(conn) == CONNECTION_BAD){
fprintf(stderr,"Connection to %s failed,%s",str,PQerrorMessage(conn));
}else{
printf("Connection success");
}
PQfinish(conn);
return EXIT_SUCCESS;
}
运行出错信息
Connection to host=localhost dbname=mydb failed,fe_sendauth: no password supplied
把str改成 host=localhost dbname=mydb user=postgres password=111
之后 出错信息
Connection to host=localhost dbname=mydb user=postgres password=111 failed,致命错误: 用户 "postgres" Password 认证失败
请高手指点下
[问题]C语言编程连接 PostgreSQL出现问题
-
- 帖子: 5
- 注册时间: 2007-04-05 14:25
-
- 帖子: 5
- 注册时间: 2006-04-16 20:59