PostgreSQL on Ubuntu Linux

PostgreSQL on Ubuntu Linux,第1张

概述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

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 onUbuntuLinux.

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,replacingsecretwith 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 IIIname=pgadmin IIIEnCoding=UTF-8Exec=pgadmin3Terminal=falseComment[en_GB]=Postgresql administrator IIIIcon=/usr/share/pixmaps/pgadmin3.xpmType=ApplicationCategorIEs=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 filepg_hba.confto change authentification method for accessing Postgresql database.

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

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

# TYPE  DATABASE    USER        IP-ADDRESS        IP-MASK           METHODhost    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 mynewusersudo -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
总结

以上是内存溢出为你收集整理的PostgreSQL on Ubuntu Linux全部内容,希望文章能够帮你解决PostgreSQL on Ubuntu Linux所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1182459.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存