PostgreSQL on Ubuntu Linux

前端之家收集整理的这篇文章主要介绍了PostgreSQL on Ubuntu Linux前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

@H_403_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 supports a large part of the sql standard and is designed to be extensible by users in many aspects.@H_403_1@

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.@H_403_1@

This is a simple walk-through to install the Postgresql database server and the PgAdmin administration application onUbuntuLinux.@H_403_1@

Installing The Database Server

To install Postgresql 8.1 you may use the command line and type:@H_403_1@

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:@H_403_1@

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:@H_403_1@

sudo -u postgres psql template1

Then at the new prompt,type these two commands,replacingsecretwith the new password (up to you)@H_403_1@

ALTER USER postgres WITH PASSWORD 'secret';
 /q

Create Database

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

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:@H_403_1@

pgadmin3

To get a menu entry for pgAdmin do the following…@H_403_1@

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.@H_403_1@

Managing The Server

Change Authentication Method

We need to edit filepg_hba.confto change authentification method for accessing Postgresql database.@H_403_1@

sudo cp /etc/postgresql/pg_hba.conf /etc/postgresql/pg_hba.confbak
sudo 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:@H_403_1@

# 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.@H_403_1@

Create a Database

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

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!@H_403_1@

sudo /etc/init.d/postgresql-8.1 restart
原文链接:https://www.f2er.com/postgresql/195019.html

猜你在找的Postgre SQL相关文章