文档章节

PostgreSQL on Ubuntu Linux

 大东家
发布于 2015/01/13 10:29
字数 501
阅读 18
收藏 0

PostgreSQL is a powerful object-relational database management system, provided under a flexible BSD-style license. PostgreSQL contains many advanced features, is very fast and standards compliant. It supports a large part of the SQL standard and is designed to be extensible by users in many aspects.

Some of the features are: ACID transactions, foreign keys, views, sequences, sub queries, triggers, user-defined types and functions, outer joins, multi version concurrency control. Graphical user interfaces and bindings for many programming languages are available as well.

This is a simple walk-through to install the PostgreSQL database server and the PgAdmin administration application on Ubuntu Linux.

Installing The Database Server

To install PostgreSQL 8.1 you may use the command line and type:

sudo apt-get install postgresql-8.1

GUI for PostgreSQL

To install pgAdmin III, a handy GUI for PostgreSQL, you may use the command line and type:

sudo apt-get install pgadmin3

Basic Server Setup

Set Password

To start off, we need to change the PostgreSQL postgres user password, we will not be able to access the server otherwise. As the “postgres” Linux user, we will execute the psql command, in a terminal type:

sudo -u postgres psql template1

Then at the new prompt, type these two commands, replacing secret with the new password (up to you ;) )

ALTER USER postgres WITH PASSWORD 'secret';
 /q

Create Database

To create the first database, which we will call “mydatabase”, simply type :

sudo -u postgres createdb mydatabase

Using pgAdmin III GUI

To get an idea of what PostgreSQL can do, you may start by firing up a graphical client. In a terminal type:

pgadmin3

To get a menu entry for pgAdmin do the following…

sudo gedit /usr/share/applications/pgadmin.desktop
[Desktop Entry] Comment= PostgreSQL Administrator III
Name=pgAdmin III
Encoding=UTF-8
Exec=pgadmin3
Terminal=false
Comment[en_GB]=PostgreSQL Administrator III
Icon=/usr/share/pixmaps/pgadmin3.xpm
Type=Application
Categories=GNOME;Application;Database;System;
Name[en_GB]=pgAdmin III

Then save the file and exit gedit. You should find the launcher in the System Tools section of the Applications menu.

Managing The Server

Change Authentication Method

We need to edit file pg_hba.conf to change authentification method for accessing PostgreSQL database.

sudo cp /etc/postgresql/pg_hba.conf /etc/postgresql/pg_hba.confbak
sudo gedit /etc/postgresql/pg_hba.conf

For example, if you want postgres to manage its own users (not linked with system users), you will add the following line:

# TYPE  DATABASE    USER        IP-ADDRESS        IP-MASK           METHOD
host    all         all         10.0.0.0       255.255.255.0    password

Which means that on your local network (10.0.0.0/24 – replace with your own local network !), postgres users can connect through the network to the database providing a classical couple user / password.

Create a Database

To create a database with a user that have full rights on the database, use the following command:

sudo -u postgres createuser -D -A -P mynewuser
sudo -u postgres createdb -O mynewuser mydatabase

That’s it, now all you have to do is restart the server and all should be working!

sudo /etc/init.d/postgresql-8.1 restart

© 著作权归作者所有

粉丝 22
博文 257
码字总数 112112
作品 0
长沙
项目经理
私信 提问
如何在 Ubuntu 上安装和配置 PostgreSQL

本教程中,你将学习如何在 Ubuntu Linux 上安装和使用开源数据库 PostgreSQL。 PostgreSQL (又名 Postgres) 是一个功能强大的自由开源的关系型数据库管理系统 (RDBMS) ,其在可靠性、稳定性、...

作者: Sergiu
10/20
0
0
Ubuntu 12.04下PostgreSQL-9.1安装与配置详解(在线安装)

说明: 我是用root用户在终端登陆的,如果是非root用户,那在命令前需要加上"sudo",你懂的... 第一步:在Ubuntu下安装Postgresql 1.使用 apt-get install安装 root@server2-virtual-machine...

今幕明
2015/03/17
168
0
[杂记]PostgreSQL命令行使用

关于PostgreSQL的使用 平台: Ubuntu 12.04 & 14.04 版本: PostgreSQL 9.3.4 PostgreSQL安装 详见官网安装过程 添加用户 初次安装后,默认生成一个名为postgres的数据库和一个名为postgres的数...

Haffe
2014/10/04
1K
0
在Ubuntu 12.04中使用最新的Eclipse版本调试跟踪最新的PostgreSQL源代码

1 写在最前 大概三周前就已经想把这篇文章发出来了,但是苦于各种杂事,今天终于有空来整理一下了。进入正题前,我想说的是,目前网上的很多关于PostgreSQL(以下简称PG)源代码分析环境搭建...

鄂世嘉
2013/12/29
426
2
Ubuntu Server + openerp(三)

继上篇,系统我们装好了,当然接下我们需要更新系统: $ sudo apt-get update $ sudo apt-get upgrade 更新系统需要一段时间,由于我们安装的是一个基本系统,并不存在数据库等,让我们来安装...

Elvin_Wang
2012/12/28
749
0

没有更多内容

加载失败,请刷新页面

加载更多

kail 树莓派中文字体设置

1修改源信息 vi /etc/apt/sources.list 将原有源信息注释,替换为以下任意源信息 #中科大deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contribdeb-src http://mirr...

飞翔的白云
1分钟前
0
0
关于[Warning] IPv4 forwarding is disabled. Networking will not work的报错处理

在Linux虚拟机中操作Docker ,构建Docker镜像时出现报错 \[Warning\] IPv4 forwarding is disabled. Networking will not work 处理办法: 修改/etc/sysctl.conf文件,添加 net.ipv4.ip_fo...

芥末无敌
2分钟前
1
0
Redis

red

天空飘来五个字儿
3分钟前
2
0
Python学习笔记--传值和传地址

写了下面四个函数: def ChangeInt(num): #改变整数为-1 num = -1a = 1ChangeInt(a)print(a)#-------------------------------------def ChangeList1(ls, index): #改变...

myctrd
4分钟前
1
0
人脸识别技术开发功能,人脸识别二次开发

人脸识别系统是针对机关单位的实际情况,基于人脸识别技术开发的机关、企业职员考勤、门禁、食堂餐饮、停车等信息管理系统。实现“一张笑脸,通行单位”的功能。人脸识别系统使用先进的人脸识...

非思丸智能FaceTo
4分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部