六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 129|回复: 0

初识linux下postgresql数据库并且简单使用(原创)

[复制链接]

升级  56.05%

691

主题

691

主题

691

主题

探花

Rank: 6Rank: 6

积分
2121
 楼主| 发表于 2013-1-30 01:27:30 | 显示全部楼层 |阅读模式
rpm -Uvh --nodeps 'ls'
安装下列列出的rpm……
rpm -qa|grep postgre
查看所有相关于postgre的安装包所安装后的文件目录……
service postgresql start
启动postgresql服务
#su postgres 用postgres用户权限登陆

bash-2.05b$createdb 建立数据库
bash-2.05b$psql

*********************************
Welcome to psql 7.3.4, the Postgresql interactive terminal
*********************************

bashv-2.05$vi /var/lib/pgsql/data/postgresql.conf
编辑postgresql配置文件
vi /var/lib/pgsql/data/pg_hba.conf
查看远端访问限制,如果需要远端机器连接和操纵本地数据库,就需要加入远端IP地址和子网掩码……

建立用户
CREATE USER RootHackComputerInt WITH PASSWORD 'RootHackComputerInt';

建立一个RootHackComputerInt拥有的数据库
CREATE DATABASE RootHackComputerInt WITH OWNER = netkiller TEMPLATE = template0
ENCODING='UNICODE';/**(编码为UNICODE)*/
#\duList of database users
#\lList of databases

#\qexit the postgresql(psql)

hash-2.0.5b$ createlang plpgsql netkiller(/**?????*/)

[root@linux software]# service postgersql restart

[root@linux software]#psql -h127.0.0.1 -URootHackComputerInt RootHackComputerInt
password:*********
用帐户 RootHackComputerInt密码RootHackComputerInt登陆…………
********************************************************
Welcome to psql 7.3.4,the PostgreSQL interactive terminal.
************************************************************
postgres 只能用于UNIX Domain Socket 方式登陆(/tmp/.s.PGSQL.5432)
不能在TCP/IP Socket模式下登陆
ls -la /tmp
file /tmp/.s.PGSQL.5432
查看文件类型,所以/tmp/.s.PGSQL.5432显示类型为/tmp/.s.PGSQL.5432:socket
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表