Ubuntu Install, use PostgreSQL database

Source: Internet
Author: User
Tags ming psql postgres database


Ubuntu Install, use PostgreSQL database


$ sudo apt-get install PostgreSQL


$ sudo passwd postgres (postgres account's home directory:/var/lib/postgresql)


Installing the Postgres Graphical client


$ sudo apt-get install pgadmin3 (call to enter pgadmin3 directly on the command line)



Main configuration files for Postgres


/etc/postgresql/9.1/main/pg_hba.conf (The Connection database authentication method) and postgresql.conf (the database


Configuration files) (before the proposed modifications are backed up)


The bin command path for PostgreSQL:


/usr/lib/postgresql/8.4/bin


Default does not write absolute path cannot be called, can do under soft link:


# ln-s/usr/lib/postgresql/8.4/bin/*/usr/bin/(some would have been, indifferent)



Postgres Database Storage Path:


/var/lib/postgresql/9.1/main/base (Note: This shows the OID of the database, not the database name)


To view the database name of the OID, execute the oid2name in the base directory



Start, close, and restart PostgreSQL


$ sudo service PostgreSQL Start\stop\restart




Under the Postgres account Command line, proceed as follows:


Create an Account


$ createuser-a-d-p-R user1


Password


Note:


-A does not allow other users to be created

-D does not allow database creation

-P Create password

-R does not allow roles to be created



Create a Database Ming


$ createdb Ming


Enter Database Ming


$ psql Ming


After entering the interface as follows


ming=#




The following steps are done in the database:



$ psql-u Postgres (can be psql directly under Postgres account)



Create an Account



postgres=# Create user "Ming" with password ' 123456 ' nocreatedb;


Establish the database and specify the owner


postgres=# CREATE DATABASE "Mingdb" with Owner= "Ming";




\l: Lists information such as owner,encoding for an existing database


\c database name: Switch database


\d: View existing tables in the current database


\d Table name: View table structure


\DU: List all users


\q: Exit



This article from "Linux" blog, declined reprint!

Ubuntu Install, use PostgreSQL database

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.