- 论坛徽章:
- 0
|
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=> |
|