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

论坛 期权论坛 脚本     
匿名技术用户   2021-1-17 10:54   604   0

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)*/

#/du List of database users

#/l List of databases


#/q exit 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

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP