PostgreSQL 9.1 [Ubuntu]

Source: Internet
Author: User

1. Installation

 
Apt-Get install postgresql-9.1

Default installation path:/etc/postgresql9.1

# Install pgadmin3 if you need an interface client

 
Sudo apt-Get install pgadmin3

 

2. Start

Sudo/etc/init. d/PostgreSQL start * Starting PostgreSQL 9.1 Database Server [OK]

3. Set Password

After the installation is complete, generate the super administrator Postgres. We need to change the password of Postgres user, otherwise we will not be able to use this database server.

 
Sudo su Postgres-C Psql template1alter user Postgres with password 'mypwd' sudo passwd Postgres # If you forget the password, you can use this to generate a new password.

4. Create a database

You cannot directly run sudo su ipvs-C createdb mydb. You need to log on to the sudo su ipvs and execute

Su ipvs # Switch user createdb mydb

5. Access Control

1. PostgreSQL does not have a simple way to manage users. You must Edit/Etc/Postgres/pg_hba.confAnd modify its default configuration (the security of the default configuration is very high)

After modification, You can execute pg_ctrl reload (or Postgres RELOAD). The modification takes effect directly without restarting.

 

2. EditThe port (5432 by default) and listening IP address (*) in/etc/Postgres. conf can connect to the database remotely.

 

User Management

 
Sudo su Postgres-C createuser-d-r-p myusersudo su Postgres-C createdb-O myuser mydb

The first command is to create a new user. This user has no permission to create a database (-D), and has no permission to create a new user (-R ). When creating a user, you will be prompted to enter the password.

The second command is to create a database'Mydb,'Myuser'As its owner.

You can also follow the steps below

 
Su postgrescreateuser-d-r-p myusercreatedb-O myuser mydbcreatedb-help # view help

Summary

1. Common commands

 
Createuser/dropuser createdb/dropdb

2. PostgreSQL interactive text Terminal

\ Copyright show release terms \ H show SQL command instructions \? Display the pgsql command description \ G or end with a semicolon (;) and run the query \ Q to exit

 

Reference: http://www.postgresql.org/download/linux/ubuntu/ # Installation

Http://wiki.ubuntu.org.cn/PostgreSQL # simple example

Http://www.postgresql.org/docs/9.1/interactive/index.html # official online documentation

Http://www.php100.com/manual/PostgreSQL8/ # Chinese documents

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.