Chinaunix

标题: Debian 安装 Postgresql 出现错误,懂的帮着看看 [打印本页]

作者: 冰力    时间: 2008-04-18 10:56
标题: Debian 安装 Postgresql 出现错误,懂的帮着看看
执行:

postgres -D /database/postgresql/data

出现错误:

HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

WARNING: could not create listen socket for "localhost"

FATAL: could not create any TCP/IP sockets

作者: netkiller    时间: 2008-04-18 11:15
PostgreSQL
Install

安装环境 ubuntu 7.10
$ sudo apt-get install postgresql-8.2

netkiller@shenzhen:~$ sudo apt-get install postgresql-8.2
               

Postgres 配置

8.1.5之后版本不在使用tcpip_socket,改用listen_addresses

去掉注释

listen_addresses = 'localhost'
               

如果有多个网络适配器可以指定 'ip' 或 '*'

postgres@Linux-server:~$ vi /etc/postgresql/8.2/main/postgresql.conf

listen_addresses = '*'

postgres@Linux-server:~$
               

访问权限

netkiller@Linux-server:~$ sudo vi /etc/postgresql/8.1/main/pg_hba.conf
host    woodart                woodart      0.0.0.0/0       md5
hostssl woodart     all                     0.0.0.0/0       md5

               

设置Postgres管理员密码

netkiller@Linux-server:~$ sudo passwd postgres
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
               

su postgres

netkiller@Linux-server:~$ su - postgres
Password:
postgres@Linux-server:~$ pwd
/var/lib/postgresql
postgres@Linux-server:~$
               

psql环境

postgres@Linux-server:~$ psql
Welcome to psql 8.1.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

postgres=#
               

退出\q

postgres=# \q
               

创建数据,用户

CREATE ROLE woodart LOGIN
  ENCRYPTED PASSWORD 'md58360b47e149f615d2d52f98d1b22431a'
  NOSUPERUSER NOINHERIT CREATEDB NOCREATEROLE;

CREATE DATABASE woodart
  WITH OWNER = woodart
       ENCODING = 'UTF8'
       TABLESPACE = pg_default;
               

使用psql登录

postgres@Linux-server:~$ psql -h127.0.0.1 -dwoodart -Uwoodart
Password for user woodart:
Welcome to psql 8.1.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)

woodart=>




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2